home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-03 | 97.0 KB | 3,735 lines | [TEXT/MPS ] |
- //----------------------------------------------------------------------------------------
- // MABuildTool.cp
- // Copyright © 1985-96 by Apple Computer, Inc. All rights reserved.
- //----------------------------------------------------------------------------------------
-
- #ifndef __UCPLUSTOOL__
- #include "UCPlusTool.h"
- #endif
-
- // MacApp
-
- #ifndef __MACAPPVERSION__
- #include "MacAppVersion.h"
- #endif
-
- #ifndef __UASSOCIATION__
- #include "UAssociation.h"
- #endif
-
- #ifndef __ULIST__
- #include "UList.h"
- #endif
-
- #ifndef __USTRINGHANDLE__
- #include "UStringHandle.h"
- #endif
-
- // Toolbox
-
- #ifndef __RESOURCES__
- #include <Resources.h>
- #endif
-
- // MPW
-
- #ifndef __INTENV__
- #include <IntEnv.h>
- #endif
-
-
- //========================================================================================
- // CONSTANTS
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // Resource IDs
- //----------------------------------------------------------------------------------------
-
- const short kHelpStr = 129; // Resource ID of the stringlist printed for help
-
- //----------------------------------------------------------------------------------------
- // Keyword IDs
- //----------------------------------------------------------------------------------------
- // set i 0
- // loop
- // find Δ/'= '[0-9]+';'/
- // break if {status}
- // replace /[0-9]+/ "{i}"
- // evaluate i={i}+1
- // end
-
- enum
- {
- kwUnspecified,
-
- kwAsm,
- kwBuildFlags,
- kwBuildFolder, // Optional folder to place the object folders for a build in
- kwC,
- kwCP,
- kwCPlusPlus,
- kwCreatorAndBundle,
- kwd,
- kwE,
- kwFat,
- kwFolderName,
- kwOutputFile,
-
- kwLib,
- kwLink,
- kwMake,
- kwMakeSym,
- kwMrC,
- kwMWC68K,
- kwMWLink68K,
- kwMWCPPC,
- kwMWLinkPPC,
- kwPPCAsm,
- kwPPCLib,
- kwPPCLink,
- kwR,
- kwRAMDisk,
- kwRenameFlag,
- kwRez,
- kwRSRC,
- kwS,
- kwSCpp,
- kwSymantec,
- kwVersion,
-
- kwAlign,
- kwNoAlign,
-
- kwAttachable,
- kwNoAttachable,
-
- kwAutoBuild,
- kwNoAutoBuild,
-
- kwClassic,
- kwNoClassic,
-
- kwContainer,
- kwNoContainer,
-
- kwCPlusLoad,
- kwNoCPlusLoad,
-
- kwDebug,
- kwNoDebug,
-
- kwDebugMsg,
- kwNoDebugMsg,
-
- kwDeluxe,
- kwNoDeluxe,
-
- kwDrag,
- kwNoDrag,
-
- kwExecute,
- kwNoExecute,
-
- kwExpandEnvVars,
- kwNoExpandEnvVars,
-
- kwFail,
- kwNoFail,
-
- kwFast,
- kwNoFast,
-
- kwGXPrinting,
- kwNoGXPrinting,
-
- kwGXViews,
- kwNoGXViews,
-
- kwInspector,
- kwNoInspector,
-
- kwLinkMap,
- kwNoLinkMap,
-
- kwLinkXRef,
- kwNoLinkXRef,
-
- kwMacApp,
- kwNoMacApp,
-
- kwMALibrary,
- kwNoMALibrary,
-
- kwModelCFM,
- kwNoModelCFM,
-
- kwModelFar,
- kwNoModelFar,
-
- //CW added
- kwModelFarCode,
- kwNoModelFarCode,
-
- //CW added
- kwModelFarData,
- kwNoModelFarData,
-
- kwNames,
- kwNoNames,
-
- kwNeedsColorQD,
- kwNoNeedsColorQD,
-
- kwNeedsFPU,
- kwNoNeedsFPU,
-
- kwNeedsGX,
- kwNoNeedsGX,
-
- kwNeedsMC68020,
- kwNoNeedsMC68020,
-
- kwNeedsMC68030,
- kwNoNeedsMC68030,
-
- kwNeedsMC68040,
- kwNoNeedsMC68040,
-
- kwNeedsSystem7,
- kwNoNeedsSystem7,
-
- kwNeedsSystem7_5,
- kwNoNeedsSystem7_5,
-
- kwNeedsVU, // Optional Virtual User support.
- kwNoNeedsVU,
-
- kwPerform,
- kwNoPerform,
-
- kwPowerTalk,
- kwNoPowerTalk,
-
- kwPP,
- kwNoPP,
-
- kwRangeCheck,
- kwNoRangeCheck,
-
- kwRun,
- kwNoRun,
-
- kwSave,
- kwNoSave,
-
- kwSeparateObjects,
- kwNoSeparateObjects,
-
- kwSmallSym,
- kwNoSmallSym,
-
- kwStatusOnly,
- kwNoStatusOnly,
-
- kwSym,
- kwNoSym,
-
- kwTemplateViews,
- kwNoTemplateViews,
-
- kwTheDebugger, // Optional The Debugger support
- kwNoTheDebugger,
-
- kwTT,
- kwNoTT,
-
- kwUserAutoBuild,
- kwNoUserAutoBuild,
-
- kwWriteTemplateViews,
- kwNoWriteTemplateViews
- };
-
- //========================================================================================
- // CLASS TMABuildTool
- //========================================================================================
-
- class TMABuildTool : public TCPlusTool
- {
- MA_DECLARE_CLASS;
-
- protected:
- Boolean fGetBuildFlags;
- Boolean fGetFolderName;
-
- Boolean fMacApp;
-
- Boolean fDebug;
- Boolean fInspector;
- Boolean fDebugMsg;
- Boolean fNames;
- Boolean fRangeCheck;
- Boolean fPerform;
- Boolean fSym;
- Boolean fSmallSym;
- Boolean fAlign;
- Boolean fAttachable;
- Boolean fSeparateObjects;
- CStr255 fSeparateObjectsFolder;
- CStr255 fBuildFolder;
- CStr255 fMAObj;
- Boolean fMALibrary;
- Boolean fCPlusLoad; // Create load/dump files for C++
-
- Boolean fModelFar;
- //CW added
- Boolean fModelFarCode;
- Boolean fModelFarData;
-
- Boolean fNeedsColorQD;
-
- // Kind of CPU
- Boolean fNeedsMC68020;
- Boolean fNeedsMC68030;
- Boolean fNeedsMC68040;
- Boolean fPowerPC;
-
- Boolean fNeedsFPU;
-
- Boolean fNeedsSystem7;
- Boolean fNeedsSystem7_5;
-
- Boolean fTemplateViews;
- Boolean fWriteTemplateViews;
-
- Boolean fAllProgress;
- Boolean fExecute;
- Boolean fAutoBuild;
- Boolean fUserAutoBuild;
- Boolean fNoFail;
- //CW added
- Boolean fFast;
- Boolean fLinkMap;
- Boolean fLinkXRef;
- Boolean fStatusOnly;
- Boolean fTimes;
- Boolean fRunAfterBuild;
- Boolean fSaveBeforeBuild;
- Boolean fExpandEnvironmentVars;
-
- Boolean fEverExported; // only need to export once
-
- Boolean fNeedsVU; // Virtual User option.
-
- Boolean fTheDebugger; // The Debugger option.
-
- Boolean fClassic;
- Boolean fModelCFM;
- Boolean fRSRC;
-
- Boolean fFat;
- Boolean fRAMDisk;
-
- Boolean fDrag;
- Boolean fGXViews;
- Boolean fGXPrinting;
- Boolean fNeedsGX;
- Boolean fPowerTalk;
-
- Boolean fContainer;
-
- short fCompiler;
-
- CStr255 fAppName68K;
- CStr255 fRAMDiskName;
-
- TStringHandle* fAsmOptions;
- TStringHandle* fEchoOptions;
- TStringHandle* fLibOptions;
- TStringHandle* fLinkOptions;
-
- TStringHandle* fCOptions;
- //CW added
- TStringHandle* fMWC68KOptions;
- TStringHandle* fMWLink68KOptions;
- TStringHandle* fMWCPPCOptions;
- TStringHandle* fMWLinkPPCOptions;
- // The following is split out from other compiler options because UMacAppUniversal.cp
- // must be compiled to run on 68000 machines. The CPlus compiler does not have compiler
- // directives to control machine options. It can only be controlled from the command
- // line.
- TStringHandle* fCPlusCPUOptions;
- TStringHandle* fCPlusOptions;
- TStringHandle* fSCOptions;
-
- TStringHandle* fPPCAsmOptions;
- TStringHandle* fPPCCOptions;
- TStringHandle* fMrCOptions;
- TStringHandle* fPPCLibOptions;
- TStringHandle* fPPCLinkOptions;
- TStringHandle* fMakeSymOptions;
-
- TStringHandle* fRunTimeModel;
-
- TStringHandle* fMakeOptions;
- TStringHandle* fRezOptions;
- TStringHandle* fCreatorAndBundleOptions;
-
- TList* fTargStringList;
- TStringHandle* fOptionFlags;
-
- FILE* fOutputFile;
- FILE* fMakeFile;
-
- CStr255 fStartPath;
-
- TAssociation* fRenameFlagsPairs;
-
- CStr255 fXLinkMap;
- CStr255 fXLinkXRef;
- CStr255 fXUAppName_h;
- CStr255 fXUAppName_cp;
- CStr255 fXUAppName_cp_o;
- CStr255 fXMAppName_cp;
- CStr255 fXMAppName_cp_o;
- CStr255 fXAppName_cp;
- CStr255 fXAppName_cp_o;
-
- CStr255 fBuildFlags;
-
- CStr255 fAppPath;
- CStr255 fAppName;
- CStr255 fBuildFolderAppName;
- CStr255 fIncApp;
- CStr255 fSrcApp;
- CStr255 fObjApp;
- CStr255 fMAMakeFileExtension;
- Boolean fAutomake;
- Boolean fAutorez;
- Boolean fAnyCPlus;
-
- public:
- TMABuildTool(); // constructor
-
- virtual ~TMABuildTool();
- // Destructor
-
- void IMABuildTool(int argc, char** argv);
-
- void GetRenameFlags();
-
- virtual void DoProcessFileArg(const CStr255& arg); // override
-
- virtual void DoProcessOptionArg(short kw); // override
-
- virtual void DoShowUsage(); // override
-
- virtual void DoStartProgress(); // override
-
- virtual void DoToolAction(); // override
-
- virtual void InstallKeyWords(); // override
-
- void CatenateToSourceOptionStrings(const CStr255& newText);
-
- void Echo(const CStr255& aStr);
-
- void Execute(const CStr255& aStr);
-
- void SetIE(const CStr255& theVariable,
- TStringHandle* theValue);
-
- void SetIE(const CStr255& theVariable,
- const CStr255& theValue);
-
- void CreateFolder(const CStr255& name);
-
- Boolean Exists(const CStr255& theFile);
-
- void Failed(const CStr255& aStr);
-
- void CheckKeywords();
-
- void GetAutoBuild();
- void AddAutoBuilds();
- void AutoBuildTarget(const CStr255& autoBuildExtension);
- void AddTargets(CStr255& targetNames);
-
- void DoOptionFlags_Part1();
-
- void DoOptionFlags_Part2();
-
- void OutputOptionFlags();
-
- void ParseTargetName(CStr255& targetName);
-
- // Boolean CheckSources(const CStr255& srcVar, const CStr255& srcFile,
- // const CStr255& objVar, const CStr255& objFile);
- //
- void CreateBuildFolder();
-
- void CreateObjectsFolder();
-
- void DoAllTargets();
-
- void DoATarget_Part1();
- void DoATarget_Part2();
-
- void ExpandEnvironmentVars();
-
- void ExportEnvironmentVars();
-
- void CreateMakeFile();
- void CatenateMake(const CStr255& fileName);
-
- void MakeTarget();
-
- void DoOverrides();
-
- void DoDefinitions();
-
- void DoDependencies();
-
- void SetMakeVariable(const CStr255& theVariable,
- TStringHandle* theValue);
-
- void SetMakeVariable(const CStr255& theVariable,
- const CStr255& theValue);
-
- void SetMakeVariable(const CStr255& theVariable,
- Boolean theValue);
-
- void SetMakeVariable(const CStr255& aString);
-
- void SetMakeIE(const CStr255& theVariable);
- // Set a make variable to the same as the corresponding integrated
- // environment variable.
-
- void SetMakeIE(const CStr255& theVariable,
- const CStr255& theIEVariable);
- // Set a make variable to the same as the corresponding integrated
- // environment variable.
-
- void OutputMakeVariables();
-
- void OutputTheEnd();
-
- void SetOutputFile(const CStr255& outputFileName);
- };
-
-
- TMABuildTool* gMABuildTool; // The tool
- CStr255 gDirectorySeparator; // : or / as required by host filesystem }
-
- //========================================================================================
- // GLOBAL Procedures
- //========================================================================================
- #undef Inherited
-
- static Boolean IEgetenv(const char* envName, CStr255& envValue);
- static void SubstituteInString(CStr255& s);
- static Boolean FindVariable(const CStr255& s, short& varBegin, short& varLength);
-
- static void CatenateFile(FILE* fromFile, FILE* toFile);
- static void CatenateFile(const CStr255& fileName, FILE* toFile);
- static void PathNameFromDirID(long dirID, short vRefNum, CStr255& FullPathName);
-
- //----------------------------------------------------------------------------------------
- // IEgetenv:
- //----------------------------------------------------------------------------------------
- #pragma segment Main
-
- // our own version to map to the Pascal routine with the same name
- Boolean IEgetenv(const char* envName, CStr255& envValue)
- {
- envValue.Empty(); // initialize envValue
- char * p = getenv(envName); // try and get the variable
- if (p != NULL)
- envValue = p; // copy value if it exists
- return (p != NULL);
- }
-
- //----------------------------------------------------------------------------------------
- // SubstituteInString:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void SubstituteInString(CStr255& s)
- {
- short varBegin = 0;
- short varLength;
- while (FindVariable(s, varBegin, varLength))
- {
- CStr255 varName = s.Copy(varBegin + 1, varLength - 2);
- CStr255 value;
- if (IEgetenv(varName, value))
- {
- s.Delete(varBegin, varLength);
- s.Insert(value, varBegin);
- varBegin = 0;
- }
- else
- varBegin += varLength - 1; // skip unknown variable
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FindVariable:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- Boolean FindVariable(const CStr255& s, short& varBegin, short& varLength)
- {
- // Returns the position and size of an embedded variable, including the {}
-
- Boolean found = FALSE;
- varLength = 0;
- short sLength = s.Length();
- for (short i = varBegin + 1; i <= sLength; i++)
- {
- if (s[i] == '{')
- {
- varBegin = i;
- }
- else if ((varBegin > 0) && (s[i] == '}'))
- {
- varLength = i - varBegin + 1;
- found = TRUE;
- break;
- }
- }
- return found;
- }
-
- //----------------------------------------------------------------------------------------
- // CatenateFile:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void CatenateFile(FILE* fromFile, FILE* toFile)
- {
- char* buffer = (char*)malloc(BUFSIZ);
- FailNIL(buffer);
- while (!feof(fromFile))
- {
- size_t n = fread(buffer, 1, BUFSIZ, fromFile);
- if (n > 0)
- fwrite(buffer, 1, n, toFile);
- }
- free(buffer);
- }
-
- //----------------------------------------------------------------------------------------
- // CatenateFile:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void CatenateFile(const CStr255& fileName, FILE* toFile)
- {
- FILE* fromFile = fopen(fileName, "r");
- CatenateFile(fromFile, toFile);
- fclose(fromFile);
- }
-
- //========================================================================================
- // CLASS TMABuildTool
- //========================================================================================
- #undef Inherited
- #define Inherited TCPlusTool
-
- #pragma segment ANonRes
- MA_DEFINE_CLASS_M1(TMABuildTool, Inherited);
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool constructor
- //----------------------------------------------------------------------------------------
- #pragma segment TInit
-
- TMABuildTool::TMABuildTool()
- {
- // setup the default options
- fGetBuildFlags = FALSE;
- fGetFolderName = FALSE;
-
- fMacApp = TRUE;
- fDebug = FALSE;
- fInspector = FALSE;
- fDebugMsg = FALSE;
- fNames = FALSE;
- fRangeCheck = FALSE;
- fPerform = FALSE;
- fSym = FALSE;
- fSmallSym = FALSE;
- fAlign = TRUE;
- fAttachable = FALSE;
- fSeparateObjects = TRUE;
- // fSeparateObjectsFolder = "";
- // fBuildFolder = "";
- fMALibrary = TRUE;
- fCPlusLoad = TRUE;
-
- fModelFar = FALSE;
- //CW added
- fModelFarCode = FALSE;
- fModelFarData = FALSE;
-
- fNeedsColorQD = TRUE;
- fNeedsGX = FALSE;
- fNeedsMC68020 = TRUE;
- fNeedsMC68030 = FALSE;
- fNeedsMC68040 = FALSE;
- fPowerPC = FALSE;
- fNeedsFPU = FALSE;
- fNeedsSystem7 = TRUE;
- fNeedsSystem7_5 = FALSE;
-
- fTemplateViews = TRUE;
- fWriteTemplateViews = FALSE;
- fAllProgress = FALSE;
- fExecute = TRUE;
- fAutoBuild = FALSE;
- fUserAutoBuild = TRUE;
- fNoFail = FALSE;
- fFast = FALSE;
- fLinkMap = FALSE;
- fLinkXRef = FALSE;
- fStatusOnly = FALSE;
- fTimes = FALSE;
- fRunAfterBuild = FALSE;
- fSaveBeforeBuild = FALSE;
- fExpandEnvironmentVars = FALSE;
- fEverExported = FALSE;
- fNeedsVU = FALSE;
- fTheDebugger = FALSE;
-
- fCompiler = kwUnspecified;
-
- fClassic = FALSE;
- fModelCFM = FALSE;
- fRSRC = FALSE;
- fFat = FALSE;
- fRAMDisk = FALSE;
-
- fDrag = FALSE;
- fGXPrinting = FALSE;
- fGXViews = FALSE;
- fPowerTalk = FALSE;
-
- fContainer = FALSE;
-
- fAsmOptions = NULL;
- fEchoOptions = NULL;
- fLibOptions = NULL;
- fLinkOptions = NULL;
-
- fCOptions = NULL;
- //CW added
- fMWC68KOptions = NULL;
- fMWLink68KOptions = NULL;
- fMWCPPCOptions = NULL;
- fMWLinkPPCOptions = NULL;
-
- fCPlusCPUOptions = NULL;
- fCPlusOptions = NULL;
- fSCOptions = NULL;
-
- fPPCAsmOptions = NULL;
- fPPCCOptions = NULL;
- fMrCOptions = NULL;
- fPPCLibOptions = NULL;
- fPPCLinkOptions = NULL;
- fMakeSymOptions = NULL;
-
- fRunTimeModel = NULL;
-
- fMakeOptions = NULL;
- fRezOptions = NULL;
- fCreatorAndBundleOptions = NULL;
- fTargStringList = NULL;
- fOptionFlags = NULL;
- fOutputFile = NULL;
- fMakeFile = NULL;
- // fStartPath = "";
- fRenameFlagsPairs = NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool destructor
- //----------------------------------------------------------------------------------------
- #pragma segment MADestructorRes
-
- TMABuildTool::~TMABuildTool()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::IMABuildTool:
- //----------------------------------------------------------------------------------------
- #pragma segment TInit
-
- void TMABuildTool::IMABuildTool(int argc, char** argv)
- {
- TAssociation* anAssociation;
- CStr255 aString;
-
- this->ICPlusTool(argc, argv);
-
- // Try to get the appropriate separator character for directories
- if (IEgetenv("MADirectorySeparator", aString))
- gDirectorySeparator = aString;
- else
- gDirectorySeparator = ":";
-
- fOutputFile = stdout;
-
- anAssociation = new TAssociation;
- anAssociation->IAssociation();
- fRenameFlagsPairs = anAssociation;
-
- fAsmOptions = NewTStringHandle();
- fEchoOptions = NewTStringHandle();
- fLibOptions = NewTStringHandle();
- fLinkOptions = NewTStringHandle();
-
- fCOptions = NewTStringHandle();
- //CW added
- fMWC68KOptions = NewTStringHandle();
- fMWLink68KOptions = NewTStringHandle();
- fMWCPPCOptions = NewTStringHandle();
- fMWLinkPPCOptions = NewTStringHandle();
-
- fCPlusCPUOptions = NewTStringHandle();
- fCPlusOptions = NewTStringHandle();
- fSCOptions = NewTStringHandle();
- fPPCAsmOptions = NewTStringHandle();
- fPPCCOptions = NewTStringHandle();
- fMrCOptions = NewTStringHandle();
- fPPCLibOptions = NewTStringHandle();
- fPPCLinkOptions = NewTStringHandle();
- fMakeSymOptions = NewTStringHandle();
-
- fRunTimeModel = NewTStringHandle();
-
- fMakeOptions = NewTStringHandle();
- fRezOptions = NewTStringHandle();
- fCreatorAndBundleOptions = NewTStringHandle();
-
- fEchoOptions = NewTStringHandle();
-
- fTargStringList = NewList();
-
- fOptionFlags = NewTStringHandle();
-
- this->GetRenameFlags();
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::GetRenameFlags:
- //----------------------------------------------------------------------------------------
- #pragma segment TInit
-
- void TMABuildTool::GetRenameFlags()
- {
- CStr255 uglyName;
- CStr255 niceName;
-
- Handle renameFlags = Get1Resource('STR#', 1000);
- if (renameFlags)
- {
- HLock(renameFlags);
- short count = **(short **) renameFlags;
- count >>= 1; // divide by 2 to get number of pairs
- StringPtr s = (StringPtr) (*renameFlags + sizeof(short));
- while (--count >= 0)
- {
- uglyName = s;
- s += *s + 1;
-
- niceName = s;
- s += *s + 1;
-
- fRenameFlagsPairs->InsertEntry(uglyName, niceName);
- }
- HUnlock(renameFlags);
- ReleaseResource(renameFlags);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::DoShowUsage:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::DoShowUsage()
- {
- CStr255 theHelpString;
- short i;
-
- // output each string in the stringlist
- i = 1;
- GetIndString(theHelpString, kHelpStr, i);
- while (theHelpString.Length() > 0)
- {
- fprintf(stdout, "%s\n", (const char *)theHelpString);
- i++;
- GetIndString(theHelpString, kHelpStr, i);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::DoProcessFileArg:
- //----------------------------------------------------------------------------------------
- #pragma segment TInit
-
- void TMABuildTool::DoProcessFileArg(const CStr255& arg)
- {
- // Special case for MacApp as target for backward compatibility (until post 2.0)
- if (EqualString(arg, (StringPtr) "\pMacApp", FALSE, TRUE))
- {
- fAutoBuild = TRUE;
- }
- else
- {
- TStringHandle* aStringHandle = NewTStringHandle();
- aStringHandle->Catenate(arg);
- fTargStringList->InsertLast(aStringHandle);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::DoStartProgress:
- //----------------------------------------------------------------------------------------
- #pragma segment TInit
-
- void TMABuildTool::DoStartProgress()
- {
- // Don't show the copyright information if all we're getting is the folder name.
- if (fProgress && !fGetFolderName)
- {
- CStr255 theDateTimeString;
-
- IUTimeString(fStartDateTime, TRUE, theDateTimeString);
- fprintf(stdout, "# MABuildTool Start: %s",
- (const char *)theDateTimeString);
-
- IUDateString(fStartDateTime, shortDate, theDateTimeString);
- fprintf(stdout," %s\n",(const char *)theDateTimeString);
- fprintf(stdout, "\n# %s\n\n", MA_COPYRIGHT);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::CatenateToSourceOptionStrings:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::CatenateToSourceOptionStrings(const CStr255& newText)
- {
- fAsmOptions->Catenate(newText);
- fCOptions->Catenate(newText);
-
- fMWC68KOptions->Catenate(newText);
- fMWCPPCOptions->Catenate(newText);
-
- fCPlusOptions->Catenate(newText);
- fSCOptions->Catenate(newText);
- fPPCAsmOptions->Catenate(newText);
- fPPCCOptions->Catenate(newText);
- fMrCOptions->Catenate(newText);
- fRezOptions->Catenate(newText);
-
- //fMakeOptions->Catenate(newText); // Don't include Make
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::DoProcessOptionArg:
- //----------------------------------------------------------------------------------------
- #pragma segment TInit
-
- void TMABuildTool::DoProcessOptionArg(short kw)
- {
- CStr255 theNextArg;
-
- switch (kw)
- {
- // " -Asm option… # Pass through options to Assembler";
- case kwAsm:
- fAsmOptions->Catenate(" ");
- this->GetNextArg(theNextArg);
- fAsmOptions->Catenate(theNextArg);
- break;
-
- // " -BuildFolder… # Specify root object folder for this build";
- case kwBuildFolder:
- this->GetNextArg(theNextArg);
- fBuildFolder = theNextArg;
- break;
-
- // " -BuildFlags # Get the build flags for these options";
- case kwBuildFlags:
- fGetBuildFlags = TRUE;
- break;
-
- // " -C option… # Pass through options to C compiler";
- case kwC:
- fCOptions->Catenate(" ");
- this->GetNextArg(theNextArg);
- fCOptions->Catenate(theNextArg);
- break;
-
- // " -CP compiler # Specify the C++ compiler to use:";
- // " # MrC, MWC68K, MWCPPC, SCpp";
- case kwCP:
- this->GetNextArg(theNextArg);
- {
- if (theNextArg[1] == '-')
- {
- SyntaxError("'" + theNextArg + "' < missing compiler name > ");
- }
- else
- {
- Boolean found = FALSE;
- short akw;
- if (LookupKeyword(theNextArg, akw))
- {
- if (akw == kwSymantec)
- akw = kwSCpp;
-
- if ((akw == kwMrC) || (akw == kwMWC68K) ||
- (akw == kwMWCPPC) || (akw == kwSCpp))
- {
- fCompiler = akw;
- found = TRUE;
- }
- }
-
- if (!found)
- SyntaxError("'" + theNextArg + "' < not a compiler name > ");
- }
- }
- break;
-
- // " -CPlusPlus… # Pass through generic C++ compiler options";
- case kwCPlusPlus:
- this->GetNextArg(theNextArg);
-
- fCPlusOptions->Catenate(" ");
- fCPlusOptions->Catenate(theNextArg);
-
- fSCOptions->Catenate(" ");
- fSCOptions->Catenate(theNextArg);
-
- fPPCCOptions->Catenate(" ");
- fPPCCOptions->Catenate(theNextArg);
-
- fMrCOptions->Catenate(" ");
- fMrCOptions->Catenate(theNextArg);
- break;
-
- // " -CreatorAndBundle option… # Pass through options to CreatorAndBundle tool";
- case kwCreatorAndBundle:
- fCreatorAndBundleOptions->Catenate(" ");
- this->GetNextArg(theNextArg);
- fCreatorAndBundleOptions->Catenate(theNextArg);
- break;
-
- // " -d name=(TRUE|FALSE) # Set compile time variable name in all compilers";
- case kwd:
- this->GetNextArg(theNextArg);
-
- this->CatenateToSourceOptionStrings(" -d ");
- this->CatenateToSourceOptionStrings(theNextArg);
- break;
-
- // " -E # Pass through -E to Make";
- case kwE:
- fMakeOptions->Catenate(" -e");
- break;
-
- // " -Fat appname # Build a fat binary by adding the code and resources";
- // " # from a 68K application file";
- case kwFat:
- fFat = TRUE;
- this->GetNextArg(fAppName68K);
- break;
-
- // " -FolderName # Get the folder name for these options";
- case kwFolderName:
- fGetFolderName = TRUE;
- break;
-
- // " -Help # Prints this list of options to stdout";
-
- // " -Lib option… # Pass through options to Librarian";
- case kwLib:
- fLibOptions->Catenate(" ");
- this->GetNextArg(theNextArg);
- fLibOptions->Catenate(theNextArg);
- break;
-
- // " -Link option… # Pass through options to Linker";
- case kwLink:
- fLinkOptions->Catenate(" ");
- this->GetNextArg(theNextArg);
- fLinkOptions->Catenate(theNextArg);
- break;
-
- // " -Make option… # Pass through options to Make";
- case kwMake:
- fMakeOptions->Catenate(" ");
- this->GetNextArg(theNextArg);
- fMakeOptions->Catenate(theNextArg);
- break;
-
- // " -MakeSYM option… # Pass through options to MakeSYM";
- case kwMakeSym:
- fMakeSymOptions->Catenate(" ");
- this->GetNextArg(theNextArg);
- fMakeSymOptions->Catenate(theNextArg);
- break;
-
- // " -MrC option… # Pass through options to Macintosh RISC C/C++ compiler";
- case kwMrC:
- fMrCOptions->Catenate(" ");
- this->GetNextArg(theNextArg);
- fMrCOptions->Catenate(theNextArg);
- break;
-
- // " -MWC68K option… # Pass through options to Metrowerks C/C++ 68K compiler";
- case kwMWC68K:
- fMWC68KOptions->Catenate(" ");
- this->GetNextArg(theNextArg);
- fMWC68KOptions->Catenate(theNextArg);
- break;
-
- // " -MWLink68K option… # Pass through options to Metrowerks C/C++ 68K linker";
- case kwMWLink68K:
- fMWLink68KOptions->Catenate(" ");
- this->GetNextArg(theNextArg);
- fMWLink68KOptions->Catenate(theNextArg);
- break;
-
- // " -MWCPPC option… # Pass through options to Metrowerks C/C++ PPC compiler";
- case kwMWCPPC:
- fMWCPPCOptions->Catenate(" ");
- this->GetNextArg(theNextArg);
- fMWCPPCOptions->Catenate(theNextArg);
- break;
-
- // " -MWLinkPPC option… # Pass through options to Metrowerks C/C++ PPC Linker";
- case kwMWLinkPPC:
- fMWLinkPPCOptions->Catenate(" ");
- this->GetNextArg(theNextArg);
- fMWLinkPPCOptions->Catenate(theNextArg);
- break;
-
- // " -O outputFileName # Specify where the mabuild results ought to go.
- case kwOutputFile:
- this->GetNextArg(theNextArg);
- this->SetOutputFile(theNextArg);
- break;
-
- // " -PPCAsm option… # Pass through options to PPC Assembler";
- case kwPPCAsm:
- fPPCAsmOptions->Catenate(" ");
- this->GetNextArg(theNextArg);
- fPPCAsmOptions->Catenate(theNextArg);
- break;
-
- // " -PPCLib option… # Pass through options to PPC Librarian";
- case kwPPCLib:
- fPPCLibOptions->Catenate(" ");
- this->GetNextArg(theNextArg);
- fPPCLibOptions->Catenate(theNextArg);
- break;
-
- // " -PPCLink option… # Pass through options to PPC Linker";
- case kwPPCLink:
- fPPCLinkOptions->Catenate(" ");
- this->GetNextArg(theNextArg);
- fPPCLinkOptions->Catenate(theNextArg);
- break;
-
- // " -R # Pass through -R to Make and write results of Make to stdout";
- case kwR:
- fExecute = FALSE;
- fStatusOnly = TRUE;
- fMakeOptions->Catenate(" -r");
- break;
-
- // " -RAMDisk name # Use a RAM Disk for pre-compiled headers";
- case kwRAMDisk:
- fRAMDisk = TRUE;
- this->GetNextArg(fRAMDiskName);
- break;
-
- // " -RenameFlag oldname newname # Rename separate object folders";
- case kwRenameFlag:
- {
- CStr255 anotherArg;
-
- this->GetNextArg(theNextArg);
- this->GetNextArg(anotherArg);
-
- fRenameFlagsPairs->InsertEntry(theNextArg, anotherArg);
- }
- break;
-
- // " -Rez option… # Pass through options to Resource compiler";
- case kwRez:
- fRezOptions->Catenate(" ");
- this->GetNextArg(theNextArg);
- fRezOptions->Catenate(theNextArg);
- break;
-
- // " -RSRC # Build only an application .rsrc file";
- case kwRSRC:
- fRSRC = (kw == kwRSRC);
- break;
-
- // " -S # Pass through -S to Make and write results of Make to stdout";
- case kwS:
- fExecute = FALSE;
- fStatusOnly = TRUE;
- fMakeOptions->Catenate(" -s");
- break;
-
- // " -SCpp option… # Pass through options to the Symantec C++ compiler";
- case kwSCpp:
- fSCOptions->Catenate(" ");
- this->GetNextArg(theNextArg);
- fSCOptions->Catenate(theNextArg);
- break;
-
- // " -Symantec # Equivalent to -CP SCpp (for compatibility)";
- case kwSymantec:
- fCompiler = kwSCpp;
- break;
-
- // " -Version # Display the tool version";
- case kwVersion:
- {
- fprintf(stdout,"\n# MABuildTool - Release %s", MA_SHORT_VERSION);
- #if qPowerPC
- fprintf(stdout," - Power Macintosh version");
- #else
- fprintf(stdout," - 68K Macintosh version");
- #endif
- fprintf(stdout,"\n");
- }
- break;
-
- // " -[No]Align # Longword align all code and data for speed";
- case kwAlign:
- case kwNoAlign:
- fAlign = (kw == kwAlign);
- break;
-
- // " -[No]Attachable # Support for attaching scripts to objects";
- case kwAttachable:
- case kwNoAttachable:
- fAttachable = (kw == kwAttachable);
- break;
-
- // " -[No]AutoBuild # Auto-build the MacApp libraries (and any others)";
- case kwAutoBuild:
- case kwNoAutoBuild:
- fAutoBuild = (kw == kwAutoBuild);
- break;
-
- // " -[No]Classic # Build for classic 68K runtime";
- case kwClassic:
- case kwNoClassic:
- fClassic = (kw == kwClassic);
- if (fClassic)
- fModelCFM = FALSE;
- break;
-
- // " -[No]Container # OpenDoc container application";
- case kwContainer:
- case kwNoContainer:
- fContainer = (kw == kwContainer);
- break;
-
- // " -[No]CPlusLoad # Make the C++ compiler use load/dump files";
- case kwCPlusLoad:
- case kwNoCPlusLoad:
- fCPlusLoad = (kw == kwCPlusLoad);
- break;
-
- // " -[No]Debug # Turn on debugging and install debugging gear";
- case kwDebug:
- case kwNoDebug:
- fPerform = fDebug = fDebugMsg = fRangeCheck = fNames = (kw == kwDebug);
-
- // Default is to also turn on source debugging symbols,
- // but it can be turned off
- if (fDebug)
- fSym = TRUE;
- break;
-
- // " -[No]DebugMsg # Turn on extra debugging messages";
- case kwDebugMsg:
- case kwNoDebugMsg:
- fDebugMsg = (kw == kwDebugMsg);
- break;
-
- // " -[No]Deluxe # Include support for the coolest features";
- case kwDeluxe:
- case kwNoDeluxe:
- fAttachable = fDrag = fPowerTalk = (kw == kwDeluxe);
- break;
-
- // " -[No]Drag # Include support for Drag & Drop";
- case kwDrag:
- case kwNoDrag:
- fDrag = (kw == kwDrag);
- break;
-
- // " -[No]Execute # Execute the results of Make";
- case kwExecute:
- case kwNoExecute:
- fExecute = (kw == kwExecute);
- break;
-
- // " -[No]ExpandEnvVars # Expand environment vars in AppName.MakeIt";
- case kwExpandEnvVars:
- case kwNoExpandEnvVars:
- fExpandEnvironmentVars = (kw == kwExpandEnvVars);
- break;
-
- // " -[No]Fail # Stop executing after first failure";
- case kwNoFail:
- case kwFail:
- fNoFail = (kw == kwNoFail);
- break;
-
- // " -[No]Fast # Compile files in one batch (faster)";
- case kwNoFast:
- case kwFast:
- fFast = (kw == kwFast);
- break;
-
- // " -[No]GXPrinting # Include support for GX Printing";
- case kwGXPrinting:
- case kwNoGXPrinting:
- fGXPrinting = (kw == kwGXPrinting);
- break;
-
- // " -[No]GXViews # Include support for GX Views";
- case kwGXViews:
- case kwNoGXViews:
- fGXViews = (kw == kwGXViews);
- break;
-
- // " -[No]Inspector # Include hooks for the inspector";
- case kwInspector:
- case kwNoInspector:
- fInspector = (kw == kwInspector);
- break;
-
- // " -[No]LinkMap # Generate a link map in AppName.map";
- case kwLinkMap:
- case kwNoLinkMap:
- fLinkMap = (kw == kwLinkMap);
- break;
-
- // " -[No]LinkXRef # Generate a linker cross reference in AppName.xref";
- case kwLinkXRef:
- case kwNoLinkXRef:
- fLinkXRef = (kw == kwLinkXRef);
- break;
-
- // " -[No]MacApp # Build for use with MacApp";
- case kwMacApp:
- case kwNoMacApp:
- fMacApp = (kw == kwMacApp);
- break;
-
- // " -[No]MALibrary # Use library, not object files";
- case kwMALibrary:
- case kwNoMALibrary:
- fMALibrary = (kw == kwMALibrary);
- break;
-
- // " -[No]ModelCFM # Build for model CFM-68K support";
- case kwModelCFM:
- case kwNoModelCFM:
- fModelCFM = (kw == kwModelCFM);
- if (fModelCFM)
- {
- fClassic = FALSE;
- fModelFar = FALSE;
- //CW added
- fModelFarCode = FALSE;
- fModelFarData = FALSE;
- }
- break;
-
- // " -[No]ModelFar # Build for model far support";
- case kwModelFar:
- case kwNoModelFar:
- fModelFar = (kw == kwModelFar);
- //CW added
- fModelFarCode = (kw == kwModelFar);
- fModelFarData = (kw == kwModelFar);
- break;
-
- //CW added
- // " -[No]ModelFarCode # Build for model far code support";
- case kwModelFarCode:
- case kwNoModelFarCode:
- fModelFarCode = (kw == kwModelFarCode);
- break;
-
- //CW added
- // " -[No]ModelFarData # Build for model far data support";
- case kwModelFarData:
- case kwNoModelFarData:
- fModelFarData = (kw == kwModelFarData);
- break;
-
- // " -[No]Names # Include embedded debugging symbols";
- case kwNames:
- case kwNoNames:
- fNames = (kw == kwNames);
-
- // Default is to also turn on source debugging symbols,
- // but it can be turned off
- if (fNames)
- fSym = TRUE;
- break;
-
- // " -[No]NeedsColorQD # Build to require Color QuickDraw™";
- case kwNeedsColorQD:
- case kwNoNeedsColorQD:
- fNeedsColorQD = (kw == kwNeedsColorQD);
- break;
-
- // " -[No]NeedsFPU # Build to require a Floating point unit";
- case kwNeedsFPU:
- case kwNoNeedsFPU:
- fNeedsFPU = (kw == kwNeedsFPU);
- break;
-
- // " -[No]NeedsGX # Build to require GX";
- case kwNeedsGX:
- case kwNoNeedsGX:
- fNeedsGX = (kw == kwNeedsGX);
- break;
-
- // " -[No]NeedsMC68020 # Build to require a 68020";
- case kwNeedsMC68020:
- case kwNoNeedsMC68020:
- fNeedsMC68020 = (kw == kwNeedsMC68020);
- if (fNeedsMC68020)
- {
- fPowerPC = FALSE;
- }
- break;
-
- // " -[No]NeedsMC68030 # Build to require a 68030";
- case kwNeedsMC68030:
- case kwNoNeedsMC68030:
- fNeedsMC68030 = (kw == kwNeedsMC68030);
- if (fNeedsMC68030)
- {
- fPowerPC = FALSE;
- }
- break;
-
- // " -[No]NeedsMC68040 # Build to require a 68040";
- case kwNeedsMC68040:
- case kwNoNeedsMC68040:
- fNeedsMC68040 = (kw == kwNeedsMC68040);
- if (fNeedsMC68040)
- {
- fPowerPC = FALSE;
- }
- break;
-
- // " -[No]NeedsSystem7 # Build to require System 7.0 or better";
- case kwNeedsSystem7:
- case kwNoNeedsSystem7:
- fNeedsSystem7 = (kw == kwNeedsSystem7);
- break;
-
- // " -[No]NeedsSystem7 # Build to require System 7.0 or better";
- case kwNeedsSystem7_5:
- case kwNoNeedsSystem7_5:
- fNeedsSystem7_5 = (kw == kwNeedsSystem7_5);
- break;
-
- // " -[No]NeedsVU # Build for VU compatibility";
- case kwNeedsVU:
- case kwNoNeedsVU:
- fNeedsVU = (kw == kwNeedsVU);
- break;
-
- // " -[No]P # Show progress for the MABuild system";
-
- // " -[No]Perform # Include performance monitor code";
- case kwPerform:
- case kwNoPerform:
- fPerform = (kw == kwPerform);
- break;
-
- // " -[No]PowerTalk # Include support for PowerTalk Mailers";
- case kwPowerTalk:
- case kwNoPowerTalk:
- fPowerTalk = (kw == kwPowerTalk);
- break;
-
- // " -[No]PP # Have all invoked tools show progress too";
- case kwPP:
- case kwNoPP:
- fAllProgress = fProgress = (kw == kwPP);
- break;
-
- // " -[No]RangeCheck # Force range/overflow checking";
- case kwRangeCheck:
- case kwNoRangeCheck:
- fRangeCheck = (kw == kwRangeCheck);
- break;
-
- // " -[No]Run # Run after build";
- case kwRun:
- case kwNoRun:
- fRunAfterBuild = (kw == kwRun);
- break;
-
- // " -[No]Save # Auto-save all open windows before starting build";
- case kwSave:
- case kwNoSave:
- fSaveBeforeBuild = (kw == kwSave);
- break;
-
- // " -[No]SeparateObjects # Keep separate object folders for each build variation";
- case kwSeparateObjects:
- case kwNoSeparateObjects:
- fSeparateObjects = (kw == kwSeparateObjects);
- break;
-
- // " -[No]SmallSym # Try to generate smaller symbol files (slow!)";
- case kwSmallSym:
- case kwNoSmallSym:
- fSmallSym = (kw == kwSmallSym);
- fSym = TRUE;
- break;
-
- // " -[No]StatusOnly # Write results of Make to stdout";
- case kwStatusOnly:
- case kwNoStatusOnly:
- fExecute = (kw == kwNoStatusOnly);
- fStatusOnly = (kw == kwStatusOnly);
- break;
-
- // " -[No]Sym # Generate SADE-compatible symbol information";
- case kwSym:
- case kwNoSym:
- fSym = (kw == kwSym);
- if (!fSym)
- fSmallSym = FALSE;
- break;
-
- // " -[No]T # Show elapsed time for the MABuild system";
-
- // " -[No]TemplateViews # Include code to create views from templates";
- case kwTemplateViews:
- case kwNoTemplateViews:
- fTemplateViews = (kw == kwTemplateViews);
- break;
-
- // " -[No]TT # Have all invoked tools show elapsed time too";
- case kwTT:
- case kwNoTT:
- fTimes = fTime = (kw == kwTT);
- break;
-
- // " -[No]UserAutoBuild # Auto-build user-specified libraries {MAUserAutoBuild}";
- case kwUserAutoBuild:
- case kwNoUserAutoBuild:
- fUserAutoBuild= (kw == kwUserAutoBuild);
- break;
-
- // " -[No]WriteTemplateViews # Include code to write view resources"
- case kwWriteTemplateViews:
- case kwNoWriteTemplateViews:
- fWriteTemplateViews = (kw == kwWriteTemplateViews);
- break;
-
- case kwTheDebugger:
- case kwNoTheDebugger:
- fTheDebugger = (kw == kwTheDebugger);
- break;
-
- default:
- Inherited::DoProcessOptionArg(kw);
- break;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::InstallKeyWords:
- //----------------------------------------------------------------------------------------
- #pragma segment TInit
-
- void TMABuildTool::InstallKeyWords()
- {
- KeyWordStruct keywords [] =
- {
- {"Asm", kwAsm},
- {"BuildFlags", kwBuildFlags},
- {"BuildFolder", kwBuildFolder},
- {"C", kwC},
- {"CP", kwCP},
- {"CPlusPlus", kwCPlusPlus},
- {"CreatorAndBundle", kwCreatorAndBundle},
- {"d", kwd},
- {"E", kwE},
- {"Fat", kwFat},
- {"FolderName", kwFolderName},
- {"Lib", kwLib},
- {"Link", kwLink},
- {"Make", kwMake},
- {"MakeSym", kwMakeSym},
- {"MrC", kwMrC},
- {"MWC68K", kwMWC68K},
- {"MWCPPC", kwMWCPPC},
-
- {"MWLink68K", kwMWLink68K},
- {"MWLinkPPC", kwMWLinkPPC},
-
- {"O", kwOutputFile},
-
- {"PPCAsm", kwPPCAsm},
- {"PPCLib", kwPPCLib},
- {"PPCLink", kwPPCLink},
- {"R", kwR},
- {"RAMDisk", kwRAMDisk},
- {"RenameFlag", kwRenameFlag},
- {"Rez", kwRez},
- {"RSRC", kwRSRC},
- {"S", kwS},
- {"SCpp", kwSCpp},
- {"Symantec", kwSymantec},
- {"Version", kwVersion},
-
- {"Align", kwAlign}, {"NoAlign", kwNoAlign},
- {"Attachable", kwAttachable}, {"NoAttachable", kwNoAttachable},
- {"AutoBuild", kwAutoBuild}, {"NoAutoBuild", kwNoAutoBuild},
- {"Classic", kwClassic}, {"NoClassic", kwNoClassic},
- {"Container", kwContainer}, {"NoContainer", kwNoContainer},
- {"CPlusLoad", kwCPlusLoad}, {"NoCPlusLoad", kwNoCPlusLoad},
- {"Debug", kwDebug}, {"NoDebug", kwNoDebug},
- {"DebugMsg", kwDebugMsg}, {"NoDebugMsg", kwNoDebugMsg},
- {"Deluxe", kwDeluxe}, {"NoDeluxe", kwNoDeluxe},
- {"Drag", kwDrag}, {"NoDrag", kwNoDrag},
- {"Execute", kwExecute}, {"NoExecute", kwNoExecute},
- {"ExpandEnvVars", kwExpandEnvVars}, {"NoExpandEnvVars", kwNoExpandEnvVars},
- {"Fail", kwFail}, {"NoFail", kwNoFail},
- {"Fast", kwFast}, {"NoFast", kwNoFast},
- {"GXPrinting", kwGXPrinting}, {"NoGXPrinting", kwNoGXPrinting},
- {"GXViews", kwGXViews}, {"NoGXViews", kwNoGXViews},
- {"Inspector", kwInspector}, {"NoInspector", kwNoInspector},
- {"LinkMap", kwLinkMap}, {"NoLinkMap", kwNoLinkMap},
- {"LinkXRef", kwLinkXRef}, {"NoLinkXRef", kwNoLinkXRef},
- {"MacApp", kwMacApp}, {"NoMacApp", kwNoMacApp},
- {"MALibrary", kwMALibrary}, {"NoMALibrary", kwNoMALibrary},
- {"ModelCFM", kwModelCFM}, {"NoModelCFM", kwNoModelCFM},
- {"ModelFar", kwModelFar}, {"NoModelFar", kwNoModelFar},
-
- {"ModelFarCode", kwModelFarCode}, {"NoModelFarCode", kwNoModelFarCode},
- {"ModelFarData", kwModelFarData}, {"NoModelFarData", kwNoModelFarData},
-
- {"Names", kwNames}, {"NoNames", kwNoNames},
- {"NeedsColorQD", kwNeedsColorQD}, {"NoNeedsColorQD", kwNoNeedsColorQD},
- {"NeedsFPU", kwNeedsFPU}, {"NoNeedsFPU", kwNoNeedsFPU},
- {"NeedsGX", kwNeedsGX}, {"NoNeedsGX", kwNoNeedsGX},
- {"NeedsMC68020", kwNeedsMC68020}, {"NoNeedsMC68020", kwNoNeedsMC68020},
- {"NeedsMC68030", kwNeedsMC68030}, {"NoNeedsMC68030", kwNoNeedsMC68030},
- {"NeedsMC68040", kwNeedsMC68040}, {"NoNeedsMC68040", kwNoNeedsMC68040},
- {"NeedsSystem7", kwNeedsSystem7}, {"NoNeedsSystem7", kwNoNeedsSystem7},
- {"NeedsSystem7_5", kwNeedsSystem7_5}, {"NoNeedsSystem7_5", kwNoNeedsSystem7_5},
- {"NeedsVU", kwNeedsVU}, {"NoNeedsVU", kwNoNeedsVU},
- {"Perform", kwPerform}, {"NoPerform", kwNoPerform},
- {"PowerTalk", kwPowerTalk}, {"NoPowerTalk", kwNoPowerTalk},
- {"PP", kwPP}, {"NoPP", kwNoPP},
- {"RangeCheck", kwRangeCheck}, {"NoRangeCheck", kwNoRangeCheck},
- {"Run", kwRun}, {"NoRun", kwNoRun},
- {"Save", kwSave}, {"NoSave", kwNoSave},
- {"SeparateObjects", kwSeparateObjects}, {"NoSeparateObjects", kwNoSeparateObjects},
- {"SmallSym", kwSmallSym}, {"NoSmallSym", kwNoSmallSym},
- {"StatusOnly", kwStatusOnly}, {"NoStatusOnly", kwNoStatusOnly},
- {"Sym", kwSym}, {"NoSym", kwNoSym},
- {"TemplateViews", kwTemplateViews}, {"NoTemplateViews", kwNoTemplateViews},
- {"TheDebugger", kwTheDebugger}, {"NoTheDebugger", kwNoTheDebugger},
- {"TT", kwTT}, {"NoTT", kwNoTT},
- {"UserAutoBuild", kwUserAutoBuild}, {"NoUserAutoBuild", kwNoUserAutoBuild},
- {"WriteTemplateViews", kwWriteTemplateViews}, {"NoWriteTemplateViews", kwNoWriteTemplateViews}
- };
-
- Inherited::InstallKeyWords();
-
- for (short i = 0; i < sizeof(keywords) / sizeof(KeyWordStruct); i++)
- this->InstallKeyWord(keywords[i].keyword, keywords[i].keyvalue);
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::Execute:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::Execute(const CStr255& aStr)
- {
- fprintf(fOutputFile,"%s\n", (const char *)aStr);
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::SetIE:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::SetIE(const CStr255& theVariable,
- TStringHandle* theValue)
- {
- fprintf(fOutputFile, "SET %s \"", (const char *)theVariable);
- theValue->WriteToFile(fOutputFile);
- fprintf(fOutputFile, "\"\n");
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::SetIE:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::SetIE(const CStr255& theVariable,
- const CStr255& theValue)
- {
- fprintf(fOutputFile, "SET %s \"%s\"\n", (const char *)theVariable, (const char *)theValue);
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::Echo:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::Echo(const CStr255& aStr)
- {
- fprintf(fOutputFile,"{MAEcho} %s\n",(const char *)aStr);
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::CreateFolder:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::CreateFolder(const CStr255& name)
- {
- if ((name.Length() > 0) && !Exists(name))
- {
- long dirID;
- if (DirCreate(0, 0, name, &dirID) != noErr)
- {
- this->Failed("Unable to create folder: " + name);
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::Exists:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- Boolean TMABuildTool::Exists(const CStr255& theFile)
- {
- CStr255 fileName = theFile;
-
- // Return true if the file or directory exists
- CInfoPBRec aCInfoPBRec;
-
- aCInfoPBRec.hFileInfo.ioCompletion = NULL;
- aCInfoPBRec.hFileInfo.ioNamePtr = (StringPtr)&fileName;
- aCInfoPBRec.hFileInfo.ioVRefNum = 0;
- aCInfoPBRec.hFileInfo.ioFRefNum = 0;
- aCInfoPBRec.hFileInfo.ioFDirIndex = 0;
- aCInfoPBRec.hFileInfo.ioDirID = 0;
-
- return (PBGetCatInfoSync(&aCInfoPBRec) == noErr) && (aCInfoPBRec.hFileInfo.ioResult == noErr);
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::Failed:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::Failed(const CStr255& aStr)
- {
- this->Echo("MABuild: " + aStr);
- this->Echo("MABuild of {XAppName} failed: `DATE`");
- this->Execute("{MAFailed}");
-
- if (fNoFail)
- this->SetIE("XRunStatus", "1");
- else
- this->Execute("EXIT 1");
- }
-
- //----------------------------------------------------------------------------------------
- // PathNameFromDirID:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void PathNameFromDirID(long dirID, short vRefNum, CStr255& FullPathName)
- {
- const short fsRtDir = 2;
- CInfoPBRec Block;
- CStr255 directoryName;
- OSErr err;
-
- FullPathName.Empty();
- Block.hFileInfo.ioNamePtr = (StringPtr)&directoryName;
- Block.dirInfo.ioDrParID = dirID;
-
- do
- {
- Block.hFileInfo.ioVRefNum = vRefNum;
- Block.hFileInfo.ioFDirIndex = - 1;
- Block.dirInfo.ioDrDirID = Block.dirInfo.ioDrParID;
- err = PBGetCatInfoSync(&Block);
-
- directoryName = directoryName + ":";
-
- FullPathName = directoryName + FullPathName;
- } while (Block.dirInfo.ioDrDirID != fsRtDir);
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::CheckKeywords:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::CheckKeywords()
- {
- // Resolve matrix of options.
-
- if (fNeedsSystem7_5)
- fNeedsSystem7 = TRUE;
-
- if (fNeedsGX)
- {
- fGXPrinting = TRUE;
- fGXViews = TRUE;
- }
-
- if (fModelCFM)
- {
- if (fCompiler == kwUnspecified)
- fCompiler = kwSCpp;
-
- fModelFar = FALSE;
-
- fModelFarCode = FALSE;
- fModelFarData = FALSE;
-
- fNeedsMC68030 = TRUE;
- fPowerPC = FALSE;
- fNeedsSystem7 = TRUE;
- }
-
- if (fClassic)
- {
- if (fCompiler == kwUnspecified)
- fCompiler = kwSCpp;
- fPowerPC = FALSE;
- }
-
- // Default the compiler if none specified
-
- if (fCompiler == kwUnspecified)
- {
- if (fPowerPC)
- fCompiler = kwMrC;
- else
- {
- fCompiler = kwSCpp;
- if (!fModelCFM)
- fClassic = TRUE;
- }
- }
-
- // Force other options that are dependent on the compiler
-
- if ((fCompiler == kwMrC) || (fCompiler == kwMWCPPC))
- {
- fNames = FALSE;
- fPerform = FALSE;
- fModelFar = FALSE;
-
- fModelFarCode = FALSE;
- fModelFarData = FALSE;
-
- fNeedsColorQD = TRUE;
- fNeedsMC68020 = FALSE;
- fNeedsMC68030 = FALSE;
- fNeedsMC68040 = FALSE;
- fPowerPC = TRUE;
- fNeedsFPU = TRUE;
- fNeedsSystem7 = TRUE;
- }
-
- if (fCompiler == kwMWC68K)
- fPerform = FALSE;
-
- if ((fCompiler == kwSCpp) || (fCompiler == kwMWC68K))
- fPowerPC = FALSE;
-
- if ((fCompiler != kwMWCPPC) && (fCompiler != kwMWC68K))
- fFast = FALSE;
-
- if (!fProgress)
- fEchoOptions->Catenate(" ∑ Dev:NULL ");
-
- if (!fPowerPC)
- {
- if (fDebug)
- fNames = TRUE;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::GetAutoBuild:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::GetAutoBuild()
- {
- if (fUserAutoBuild)
- {
- CStr255 MAUserAutoBuild;
- if (IEgetenv("MAUserAutoBuild", MAUserAutoBuild) && !MAUserAutoBuild.IsEmpty())
- this->AddTargets(MAUserAutoBuild);
- }
-
- if (fAutoBuild)
- {
- CStr255 targetNames;
- Boolean defined;
- if (fPowerPC)
- defined = IEgetenv("MAAutoBuildPowerPC", targetNames);
- else
- defined = IEgetenv("MAAutoBuild", targetNames);
-
- if (defined && !targetNames.IsEmpty())
- this->AddTargets(targetNames);
-
- this->AddAutoBuilds();
- }
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::AddAutoBuilds:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::AddAutoBuilds()
- {
- CStr255 autoBuildExtension;
- if (IEgetenv("MAAutoBuildExtension", autoBuildExtension))
- {
- // Loop through the targets and get their autobuild requirements.
- // The autobuild targets are added to the front of the list.
- // Because we're using an iterator, the current index will be
- // adjusted when we insert new targets. However, we will not process
- // autobuild targets recursively, because the iterator also adjusts
- // the low bound when we insert.
-
- TStringHandle* stringHandle;
- CObjectIterator iter(fTargStringList, kIterateBackward);
- for (stringHandle = (TStringHandle*) iter.FirstObject(); iter.More(); stringHandle = (TStringHandle*) iter.NextObject())
- {
- this->ParseTargetName(stringHandle->AsStr255());
- this->AutoBuildTarget(autoBuildExtension);
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::AutoBuildTarget:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::AutoBuildTarget(const CStr255& autoBuildExtension)
- {
- // Look for a target.autobuild file
- CStr255 autobuild(fAppPath + fAppName + autoBuildExtension);
- if (Exists(autobuild))
- {
- FILE* autobuildFile = fopen(autobuild, "r");
- if (autobuildFile)
- {
- char targetNames[256];
- while (fgets(targetNames, 255, autobuildFile))
- {
- short l = strlen(targetNames) - 1;
- if ((l > 0) && (targetNames[l] == '\n') || (targetNames[l] == '\r'))
- targetNames[l] = 0;
-
- this->AddTargets(CStr255(targetNames));
- }
- fclose(autobuildFile);
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::AddTargets:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::AddTargets(CStr255& targetNames)
- {
- while (targetNames.Length() > 0)
- {
- short i = targetNames.Pos(",");
- if (i == 0)
- i = targetNames.Length();
- else
- i = i - 1;
-
- TStringHandle* stringHandle = NewTStringHandle();
- stringHandle->Catenate(targetNames.Copy(1, i));
- fTargStringList->InsertFirst(stringHandle);
- targetNames.Delete(1, (short)Min(i + 1, targetNames.Length())); // toss the target & ,
- }
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::DoOptionFlags_Part1:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::DoOptionFlags_Part1(void)
- {
- if (fRSRC || fPowerPC)
- {
- // Using MetroWerks or Symantec, so define a variable stating this. This will only be used in strategic places in some
- // resources where CODE's are included. Since we don't want this, we'll condition them with #ifdef qNoCode.
-
- //this->CatenateToSourceOptionStrings(" -d qNoCode=TRUE");
- fRezOptions->Catenate(" -d qNoCode=TRUE");
- }
- else
- fRezOptions->Catenate(" -d qNoCode=FALSE");
-
- // Building for use with MacApp?
- if (fMacApp)
- this->CatenateToSourceOptionStrings(" -d qMacApp=TRUE");
- else
- this->CatenateToSourceOptionStrings(" -d qMacApp=FALSE");
-
- if (fAlign)
- {
- fLinkOptions->Catenate(" -ac 4 -ad 4");
- fRezOptions->Catenate(" -align longword");
- }
-
- // process elapsed time indication
- if (fTimes)
- {
- CStr255 aString(" -t");
-
- fAsmOptions->Catenate(aString);
- fCreatorAndBundleOptions->Catenate(aString);
- fCOptions->Catenate(aString);
- fCPlusOptions->Catenate(aString);
- fPPCAsmOptions->Catenate(aString);
- }
-
- // Progress indication
- if (fAllProgress)
- {
- CStr255 aString(" -p");
-
- this->CatenateToSourceOptionStrings(aString);
- fLibOptions->Catenate(aString);
- fLinkOptions->Catenate(aString);
- //CW added
- fMWC68KOptions->Catenate(aString);
- fMWLink68KOptions->Catenate(aString);
- fMWCPPCOptions->Catenate(aString);
- fMWLinkPPCOptions->Catenate(aString);
-
- fCreatorAndBundleOptions->Catenate(aString);
- fPPCLibOptions->Catenate(aString);
- fPPCLinkOptions->Catenate(aString);
- fMakeSymOptions->Catenate(aString);
- }
-
- if (fPowerPC)
- {
- // PreSystem 7.5 support
- if (fNeedsSystem7_5)
- {
- fOptionFlags->Catenate("75");
- this->CatenateToSourceOptionStrings(" -d qNeedsSystem7_5=TRUE -d SystemSevenFiveOrLater=TRUE");
- }
- else
- this->CatenateToSourceOptionStrings(" -d qNeedsSystem7_5=FALSE -d SystemSevenFiveOrLater=FALSE");
-
- // System 7.0, ColorQD support is always on, FPU is always off
- if (!fNeedsSystem7_5)
- fOptionFlags->Catenate("S7");
- this->CatenateToSourceOptionStrings(" -d qNeedsAppleEventMgr=TRUE");
- this->CatenateToSourceOptionStrings(" -d qNeedsEditionMgr=TRUE");
- this->CatenateToSourceOptionStrings(" -d qNeedsHelpMgr=TRUE");
- this->CatenateToSourceOptionStrings(" -d qNeedsProcessMgr=TRUE");
- this->CatenateToSourceOptionStrings(" -d qNeedsAliasMgr=TRUE");
- this->CatenateToSourceOptionStrings(" -d qNeedsFolderMgr=TRUE");
- this->CatenateToSourceOptionStrings(" -d qNeedsSystem7=TRUE");
- this->CatenateToSourceOptionStrings(" -d SystemSevenOrLater=TRUE");
- fOptionFlags->Catenate("Cq");
- this->CatenateToSourceOptionStrings(" -d qNeedsColorQD=TRUE");
- this->CatenateToSourceOptionStrings(" -d qNeedsFPU=FALSE");
- }
- else
- {
- // PreSystem 7.5 support
- if (fNeedsSystem7_5)
- {
- fOptionFlags->Catenate("75");
- this->CatenateToSourceOptionStrings(" -d qNeedsSystem7_5=TRUE -d SystemSevenFiveOrLater=TRUE");
- }
- else
- this->CatenateToSourceOptionStrings(" -d qNeedsSystem7_5=FALSE -d SystemSevenFiveOrLater=FALSE");
-
- // PreSystem 7.0 support
- if (fNeedsSystem7 || fNeedsSystem7_5)
- {
- if (!fNeedsSystem7_5)
- fOptionFlags->Catenate("S7");
- this->CatenateToSourceOptionStrings(" -d qNeedsAppleEventMgr=TRUE -d qNeedsEditionMgr=TRUE -d qNeedsHelpMgr=TRUE -d qNeedsProcessMgr=TRUE -d qNeedsAliasMgr=TRUE -d qNeedsFolderMgr=TRUE -d qNeedsSystem7=TRUE -d SystemSevenOrLater=TRUE");
- }
- else
- {
- this->CatenateToSourceOptionStrings(" -d qNeedsAppleEventMgr=FALSE -d qNeedsEditionMgr=FALSE -d qNeedsHelpMgr=FALSE -d qNeedsProcessMgr=FALSE -d qNeedsAliasMgr=FALSE -d qNeedsFolderMgr=FALSE -d qNeedsSystem7=FALSE -d SystemSevenOrLater=FALSE");
-
- // Require System 6!
- this->CatenateToSourceOptionStrings(" -d SystemSixOrLater=FALSE");
- }
-
- // ColorQD support
- if (fNeedsColorQD)
- {
- fOptionFlags->Catenate("Cq");
- this->CatenateToSourceOptionStrings(" -d qNeedsColorQD=TRUE");
- }
- else
- this->CatenateToSourceOptionStrings(" -d qNeedsColorQD=FALSE");
-
- // 020 support
- if (fNeedsMC68020)
- {
- fOptionFlags->Catenate("20");
- this->CatenateToSourceOptionStrings(" -d qNeedsMC68020=TRUE");
- fCPlusCPUOptions->Catenate(" -mc68020");
- }
- else
- this->CatenateToSourceOptionStrings(" -d qNeedsMC68020=FALSE");
-
- // 030 support
- if (fNeedsMC68030)
- {
- fOptionFlags->Catenate("30");
- this->CatenateToSourceOptionStrings(" -d qNeedsMC68030=TRUE");
- fCPlusCPUOptions->Catenate(" -mc68020");
- }
- else
- this->CatenateToSourceOptionStrings(" -d qNeedsMC68030=FALSE");
-
- // 040 support
- if (fNeedsMC68040)
- {
- fOptionFlags->Catenate("40");
- this->CatenateToSourceOptionStrings(" -d qNeedsMC68040=TRUE");
- fCPlusCPUOptions->Catenate(" -mc68020");
- }
- else
- this->CatenateToSourceOptionStrings(" -d qNeedsMC68040=FALSE");
-
- // FPU support
- if (fNeedsFPU)
- {
- fOptionFlags->Catenate("Fp");
- this->CatenateToSourceOptionStrings(" -d qNeedsFPU=TRUE");
- if (fCompiler == kwMWC68K)
- fCPlusCPUOptions->Catenate(" -mc68881");
- else
- fCPlusCPUOptions->Catenate(" -mc68881 -elems881");
- }
- else
- this->CatenateToSourceOptionStrings(" -d qNeedsFPU=FALSE");
-
- } // fPowerPC
-
- // Virtual User support
- if (fNeedsVU)
- {
- fOptionFlags->Catenate("Vu");
-
- this->CatenateToSourceOptionStrings(" -d qNeedsVU=TRUE");
- }
- else
- this->CatenateToSourceOptionStrings(" -d qNeedsVU=FALSE");
-
- // The Debugger support
- if (fTheDebugger)
- {
- fOptionFlags->Catenate("J");
-
- this->CatenateToSourceOptionStrings(" -d qTheDebugger=TRUE");
- }
- else
- this->CatenateToSourceOptionStrings(" -d qTheDebugger=FALSE");
-
- // Embedded debugger names
- if (fNames)
- {
- fOptionFlags->Catenate("Nm");
- fMWC68KOptions->Catenate(" -mbg full");
-
- this->CatenateToSourceOptionStrings(" -d qNames=TRUE");
- }
- else
- {
- this->CatenateToSourceOptionStrings(" -d qNames=FALSE");
- if (!fPowerPC)
- {
- fCOptions->Catenate(" -mbg off");
- fMWC68KOptions->Catenate(" -mbg off");
- fCPlusOptions->Catenate(" -mbg off");
- fSCOptions->Catenate(" -mbg off");
- }
- }
-
- // Debugging support
- if (fDebug)
- {
- fOptionFlags->Catenate("Db");
- this->CatenateToSourceOptionStrings(" -d qDebug=TRUE");
- }
- else
- this->CatenateToSourceOptionStrings(" -d qDebug=FALSE");
-
- // Inspector support
- if (fInspector)
- {
- fOptionFlags->Catenate("In");
- this->CatenateToSourceOptionStrings(" -d qInspector=TRUE");
- }
- else
- this->CatenateToSourceOptionStrings(" -d qInspector=FALSE");
-
- // Debug messages support
- if (fDebugMsg)
- {
- fOptionFlags->Catenate("Dm");
- this->CatenateToSourceOptionStrings(" -d qDebugMsg=TRUE");
- }
- else
- this->CatenateToSourceOptionStrings(" -d qDebugMsg=FALSE");
-
- // Perform support
- if (fPerform)
- {
- fOptionFlags->Catenate("Pe");
- this->CatenateToSourceOptionStrings(" -d qPerform=TRUE");
- }
- else
- this->CatenateToSourceOptionStrings(" -d qPerform=FALSE");
-
- // RangeCheck support
- if (fRangeCheck)
- {
- fOptionFlags->Catenate("Ra");
- this->CatenateToSourceOptionStrings(" -d qRangeCheck=TRUE");
- }
- else
- this->CatenateToSourceOptionStrings(" -d qRangeCheck=FALSE");
-
- // Attachability support
- if (fAttachable)
- {
- fOptionFlags->Catenate("At");
- this->CatenateToSourceOptionStrings(" -d qAttachable=TRUE");
- }
- else
- this->CatenateToSourceOptionStrings(" -d qAttachable=FALSE");
-
- // Drag & Drop support
- if (fDrag)
- {
- fOptionFlags->Catenate("Dr");
- this->CatenateToSourceOptionStrings(" -d qDrag=TRUE");
- }
- else
- this->CatenateToSourceOptionStrings(" -d qDrag=FALSE");
-
- // GX Printing support
- if (fGXPrinting)
- {
- if (!fNeedsGX)
- fOptionFlags->Catenate("Gp");
- this->CatenateToSourceOptionStrings(" -d qGXPrinting=TRUE");
- }
- else
- this->CatenateToSourceOptionStrings(" -d qGXPrinting=FALSE");
-
- // GX Views support
- if (fGXViews)
- {
- if (!fNeedsGX)
- fOptionFlags->Catenate("Gv");
- this->CatenateToSourceOptionStrings(" -d qGXViews=TRUE");
- }
- else
- this->CatenateToSourceOptionStrings(" -d qGXViews=FALSE");
-
- // NeedsGX support
- if (fNeedsGX)
- {
- fOptionFlags->Catenate("GX");
- this->CatenateToSourceOptionStrings(" -d qNeedsGX=TRUE");
- }
- else
- this->CatenateToSourceOptionStrings(" -d qNeedsGX=FALSE");
-
- // PowerTalk support
- if (fPowerTalk)
- {
- fOptionFlags->Catenate("Pt");
- this->CatenateToSourceOptionStrings(" -d qPowerTalk=TRUE");
- }
- else
- this->CatenateToSourceOptionStrings(" -d qPowerTalk=FALSE");
-
- // OpenDoc support
- if (fContainer /* || fPart */)
- {
- fOptionFlags->Catenate("OD");
- this->CatenateToSourceOptionStrings(" -d qOpenDoc=TRUE");
- }
- else
- this->CatenateToSourceOptionStrings(" -d qOpenDoc=FALSE");
-
- // Container application support
- if (fContainer)
- {
- fOptionFlags->Catenate("Ca");
- this->CatenateToSourceOptionStrings(" -d qContainer=TRUE");
- }
- else
- this->CatenateToSourceOptionStrings(" -d qContainer=FALSE");
-
- // template views support
- if (fTemplateViews)
- {
- fOptionFlags->Catenate("Te");
- this->CatenateToSourceOptionStrings(" -d qTemplateViews=TRUE");
- }
- else
- this->CatenateToSourceOptionStrings(" -d qTemplateViews=FALSE");
-
- // writing template views support
- if (fWriteTemplateViews)
- {
- fOptionFlags->Catenate("Wr");
- this->CatenateToSourceOptionStrings(" -d qWriteTemplateViews=TRUE");
- }
- else
- this->CatenateToSourceOptionStrings(" -d qWriteTemplateViews=FALSE");
-
- // symbolic debugging support
- if (fSym)
- {
- fOptionFlags->Catenate("Sm");
- this->CatenateToSourceOptionStrings(" -d qSym=TRUE");
-
- //CW added symOn and fullPath
- const CStr255 symOn = " -sym on";
- const CStr255 fullpath = " -sym full";
- if (!fPowerPC)
- {
- CStr255 aString;
-
- if (fSmallSym)
- aString = " -sym on,notypes,novars";
- else
- aString = symOn;
-
- fAsmOptions->Catenate(aString);
- fCOptions->Catenate(aString);
-
- if (fTheDebugger)
- fMWLink68KOptions->Catenate(" -sym tdb");
- fMWC68KOptions->Catenate(fullpath);
- fMWC68KOptions->Catenate(" -a6");
- fMWLink68KOptions->Catenate(fullpath);
-
- fCPlusOptions->Catenate(aString);
- fSCOptions->Catenate(aString);
- fLinkOptions->Catenate(aString);
- }
- else
- {
- fAsmOptions->Catenate(symOn);
- fPPCCOptions->Catenate(symOn);
- fMrCOptions->Catenate(symOn);
-
- // big sym support
- if (fCompiler == kwMWCPPC)
- {
- fMWCPPCOptions->Catenate(fullpath);
- fMWLinkPPCOptions->Catenate(fullpath);
- }
- else if (fSmallSym)
- {
- fPPCLibOptions->Catenate(symOn);
- fPPCLinkOptions->Catenate(symOn);
- }
- else
- {
- fPPCLibOptions->Catenate(" -sym big");
- fPPCLinkOptions->Catenate(" -sym big");
- fMakeSymOptions->Catenate(" -sym big");
- }
- }
- }
- else
- this->CatenateToSourceOptionStrings(" -d qSym=FALSE");
-
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::DoOptionFlags_Part2:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::DoOptionFlags_Part2(void)
- {
- // Model far support
- if (fCompiler == kwMWC68K)
- {
- if ((fModelFarCode && fModelFarData) || fModelFar)
- {
- fOptionFlags->Catenate("fCfD");
- fMWC68KOptions->Catenate(" -model far");
- fMWLink68KOptions->Catenate(" -model far");
-
- this->CatenateToSourceOptionStrings(" -d qModelFarData=TRUE");
- this->CatenateToSourceOptionStrings(" -d qModelFarCode=TRUE");
- }
- else if (fModelFarCode)
- {
- fOptionFlags->Catenate("fC");
-
- fMWC68KOptions->Catenate(" -model farCode");
- fMWLink68KOptions->Catenate(" -model far");
- this->CatenateToSourceOptionStrings(" -d qModelFarData=FALSE");
- this->CatenateToSourceOptionStrings(" -d qModelFarCode=TRUE");
- }
- else if (fModelFarData)
- {
- fOptionFlags->Catenate("fD");
-
- fMWC68KOptions->Catenate(" -model farData");
- fMWC68KOptions->Catenate(" -model farstrings");
- fMWC68KOptions->Catenate(" -model farvtables");
-
- this->CatenateToSourceOptionStrings(" -d qModelFarData=TRUE");
- this->CatenateToSourceOptionStrings(" -d qModelFarCode=FALSE");
- }
- else
- {
- this->CatenateToSourceOptionStrings(" -d qModelFarData=FALSE");
- this->CatenateToSourceOptionStrings(" -d qModelFarCode=FALSE");
- }
- }
- else
- {
- if (fModelFarCode || fModelFarData || fModelFar)
- {
- fModelFar = TRUE;
- fOptionFlags->Catenate("fCfD");
- fCOptions->Catenate(" -model farCode -model farData");
- fRunTimeModel->Catenate(" -model far");
-
- this->CatenateToSourceOptionStrings(" -d qModelFarData=TRUE");
- this->CatenateToSourceOptionStrings(" -d qModelFarCode=TRUE");
- }
- else
- {
- this->CatenateToSourceOptionStrings(" -d qModelFarData=FALSE");
- this->CatenateToSourceOptionStrings(" -d qModelFarCode=FALSE");
- if (!fModelCFM)
- fLinkOptions->Catenate(" -wrap");
- }
- }
-
- // Model CFM-68K support
- if (fModelCFM)
- {
- fOptionFlags->Catenate("CF");
- fRunTimeModel->Catenate(" -model cfmseg");
- this->CatenateToSourceOptionStrings(" -d qModelCFM=TRUE");
- }
- else
- {
- this->CatenateToSourceOptionStrings(" -d qModelCFM=FALSE");
- }
-
- // Classic 68K runtime support
- if (fClassic)
- {
- fOptionFlags->Catenate("Cl");
- this->CatenateToSourceOptionStrings(" -d qClassic=TRUE");
- }
- else
- {
- this->CatenateToSourceOptionStrings(" -d qClassic=FALSE");
- }
-
- // PowerPC support
- if (fPowerPC)
- {
- this->CatenateToSourceOptionStrings(" -d qPowerPC=TRUE");
- }
- else
- {
- // We're not building a native app
- this->CatenateToSourceOptionStrings(" -d qPowerPC=FALSE");
- }
-
- // Add the compiler
- switch (fCompiler)
- {
- case kwSCpp:
- fOptionFlags->Catenate("SC");
- break;
-
- case kwMrC:
- fOptionFlags->Catenate("Mr");
- break;
-
- case kwMWCPPC:
- fOptionFlags->Catenate("MW");
- break;
-
- case kwMWC68K:
- fOptionFlags->Catenate("M8");
- break;
-
- default:
- break;
- }
-
- // Process separate objects
- // Get basic name
- if (fSeparateObjects)
- {
- CStr255 tempString(fOptionFlags->AsStr255());
- if (!fRenameFlagsPairs->ValueAt(tempString, fSeparateObjectsFolder))
- fSeparateObjectsFolder = tempString;
- }
- else
- {
- if (!IEgetenv("MANoSeparateObjectsFolder", fSeparateObjectsFolder))
- fSeparateObjectsFolder.Empty();
- }
-
- // Add the prefix
- CStr255 MASeparateObjectsPrefix;
- if (IEgetenv("MASeparateObjectsPrefix", MASeparateObjectsPrefix))
- fSeparateObjectsFolder = MASeparateObjectsPrefix + fSeparateObjectsFolder;
-
- if (fSeparateObjectsFolder.Length() > 31)
- {
- fprintf(stderr, "\nMABuild: Warning: SeparateObjectsFolder '%s'; truncated to 31 characters\n",
- (const char *) fSeparateObjectsFolder);
- fSeparateObjectsFolder.Length() = 31;
- }
-
- fSeparateObjectsFolder += gDirectorySeparator;
-
- this->SetIE("SeparateObjectsFolder", fSeparateObjectsFolder);
-
- if (fRAMDisk)
- {
- fPPCCOptions->Catenate(" -y '");
- fPPCCOptions->Catenate(fRAMDiskName);
- fPPCCOptions->Catenate("'");
-
- fMrCOptions->Catenate(" -y '");
- fMrCOptions->Catenate(fRAMDiskName);
- fMrCOptions->Catenate("'");
- }
-
- // Include any unconditional options that we might want to force on unsuspecting
- // tools but haven't the gall to include in the startup file.
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::OutputOptionFlags:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::OutputOptionFlags()
- {
- // output the results.
- if (fTimes)
- fprintf(fOutputFile,"SET XStartTime %li\n",fStartDateTime);
-
- if (fRAMDisk && fCPlusLoad)
- this->SetIE("XRAMDiskLoad", "0");
-
- if (fFast)
- {
- fprintf(fOutputFile, "SET All_Cpp_Files \"\"\n");
- fprintf(fOutputFile, "SET All_Cpp_Names \"\"\n");
- fprintf(fOutputFile, "SET All_C_Files \"\"\n");
- fprintf(fOutputFile, "SET All_C_Names \"\"\n");
- }
-
- this->SetIE("MakeOptions", fMakeOptions);
- this->SetIE("XOptionFlags", fOptionFlags);
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::ParseTargetName:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::ParseTargetName(CStr255& targetName)
- {
- // find the pathname and filename
-
- SubstituteInString(targetName);
-
- fAppName = targetName;
- fAppPath.Empty();
-
- for (short i = targetName.Length(); i >= 1; i--)
- {
- if (targetName.Copy(i, gDirectorySeparator.Length()) == gDirectorySeparator)
- {
- fAppPath = targetName.Copy(1, i);
- fAppName = targetName.Copy(i + 1, targetName.Length() - i);
- break;
- }
- }
-
- // Automatically trim .MAMake off the target name if it was specified
- if (IEgetenv("MAMakeFileExtension", fMAMakeFileExtension) && !fMAMakeFileExtension.IsEmpty())
- {
- CStr255 aString(fMAMakeFileExtension);
- CStr255 bString(fAppName);
- UprStr255(aString);
- UprStr255(bString);
- short j = aString.Pos(bString);
- if ((j != 0) && (j + aString.Length() - 1 == fAppName.Length()))
- fAppName.Delete(j, aString.Length());
- }
-
- // Blank path is current path
- if (fAppPath.IsEmpty())
- fAppPath = fStartPath;
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::CheckSources:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- // Boolean TMABuildTool::CheckSources(const CStr255& srcVar, const CStr255& srcFile,
- // const CStr255& objVar, const CStr255& objFile)
- // {
- // Boolean exists = this->Exists(srcFile);
- // if (exists)
- // {
- // this->SetIE(srcVar, srcFile);
- // if (objVar.Length() > 0)
- // this->SetIE(objVar, objFile);
- // }
- // else
- // {
- // this->SetIE(srcVar, "");
- // if (objVar.Length() > 0)
- // this->SetIE(objVar, "");
- // }
- // return exists;
- // }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::CreateBuildFolder:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::CreateBuildFolder()
- {
- // Define the MAObj folder. We do this here because its used in building
- // each target. see 'Basic Definitions'/'Basic DefinitionsFT'
-
- this->SetIE("BuildFolder", fBuildFolder);
-
- if (fBuildFolder.Length() > 0)
- {
- fMAObj = fBuildFolder;
- CreateFolder(fMAObj);
-
- fMAObj += "MacApp.Lib";
- CreateFolder(fMAObj);
-
- fMAObj += gDirectorySeparator + fSeparateObjectsFolder;
- this->SetIE("MAObj", fMAObj);
- CreateFolder(fMAObj);
- }
- else
- {
- IEgetenv("MALibraries", fMAObj);
- fMAObj += fSeparateObjectsFolder;
- this->SetIE("MAObj", fMAObj);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::CreateObjectsFolder:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::CreateObjectsFolder()
- {
- // Make sure alternate build folder exists and AppName folder in build folder.
- if (fBuildFolder.Length() > 0)
- CreateFolder(fBuildFolderAppName);
-
- // Make sure separate objects folder exists
- CreateFolder(fObjApp);
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::DoAllTargets:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::DoAllTargets()
- {
- // Now process every target in fTargStringList
-
- TStringHandle* stringHandle = (TStringHandle*)(fTargStringList->First());
- while (stringHandle != NULL)
- {
- fTargStringList->Delete(stringHandle);
-
- this->ParseTargetName(stringHandle->AsStr255());// Paths can't currently be longer than this anyways! (MPW 3.1)
- stringHandle->Free();
-
- //CW had to split these up because of 32K local data limitation
- this->DoATarget_Part1();
- this->DoATarget_Part2();
-
- stringHandle = (TStringHandle*)(fTargStringList->First());
- }
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::DoATarget_Part1:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::DoATarget_Part1()
- {
- this->SetIE("XAppPath", fAppPath);
- this->SetIE("XAppName", fAppName);
-
- // Check for the MASetupExtension file
- {
- CStr255 MASetupExtension;
- if (IEgetenv("MASetupExtension", MASetupExtension))
- {
- CStr255 aString = fAppPath + fAppName + MASetupExtension;
- if (Exists(aString))
- fprintf(fOutputFile,"EXECUTE \"%s\"\n",(const char *)aString);
- }
- }
-
- // Process separate objects into the source and object pathnames…
- if (fBuildFolder.Length() > 0)
- {
- fBuildFolderAppName = fBuildFolder;
- if (fAppName == "MacApp.lib.xcoff")
- fBuildFolderAppName += "MacApp.Lib";
- else
- fBuildFolderAppName += fAppName;
- fObjApp = fBuildFolderAppName + gDirectorySeparator + fSeparateObjectsFolder;
- }
- else
- {
- fBuildFolderAppName.Empty();
- fObjApp = fAppPath + fSeparateObjectsFolder;
- }
-
- fSrcApp = fAppPath;
-
- {
- CStr255 MASourcesFolder;
- if (IEgetenv("MASourcesFolder", MASourcesFolder))
- {
- CStr255 srcAppSrc = fSrcApp + MASourcesFolder;
- if (Exists(srcAppSrc))
- fSrcApp = srcAppSrc;
- }
- }
-
- this->SetIE("ObjApp", fObjApp);
- //this->SetIE("LoadFileDir", fObjApp);
- this->SetIE("SrcApp", fSrcApp);
-
- {
- fIncApp = fAppPath;
- CStr255 MAIncludesFolder;
- if (IEgetenv("MAIncludesFolder", MAIncludesFolder))
- {
- short saveLen = fIncApp.Length();
- fIncApp += MAIncludesFolder;
- if (!Exists(fIncApp))
- fIncApp.Length() = saveLen;
- }
- this->SetIE("IncApp", fIncApp);
- }
-
- if (fProgress)
- this->Echo("\"Target Folder: ∂\"{ObjApp}∂\"\"");
-
- // Linkmap and LinkXref
- if (fLinkMap)
- {
- if (fCompiler == kwMWC68K || fCompiler == kwMWCPPC)
- fXLinkMap = "-map > \"{ObjApp}{XAppName}.map\" ";
- else if (!fPowerPC && fPerform)
- fXLinkMap = "-la -lf -l > \"{ObjApp}{XAppName}.map\" ";
- else
- fXLinkMap = "-map \"{ObjApp}{XAppName}.map\" ";
- }
- else
- fXLinkMap.Empty();
-
- //SRF this->SetIE("XLinkMap", fXLinkMap);
- this->SetMakeVariable("XLinkMap", fXLinkMap);
-
- if (fLinkXRef && (fCompiler != kwMWC68K && fCompiler != kwMWCPPC))
- fXLinkXRef = "-x \"{ObjApp}{XAppName}.xref\" ";
- else
- fXLinkXRef.Empty();
-
- //SRF this->SetIE("XLinkXRef", fXLinkXRef);
- this->SetMakeVariable("XLinkXRef", fXLinkXRef);
-
- // in C++
- fAnyCPlus = FALSE;
-
- fXUAppName_h.Empty();
- fXUAppName_cp.Empty();
- fXUAppName_cp_o.Empty();
- fXMAppName_cp.Empty();
- fXMAppName_cp_o.Empty();
- fXAppName_cp.Empty();
- fXAppName_cp_o.Empty();
-
- if (!fRSRC)
- {
- CStr255 fileName;
-
- fileName = fSrcApp + "U" + fAppName + ".h";
- if (this->Exists(fileName))
- {
- fAnyCPlus = TRUE;
- fXUAppName_h = fileName;
- }
-
- fileName = "U" + fAppName + ".cp";
- if (this->Exists(fSrcApp + fileName))
- {
- fAnyCPlus = TRUE;
- fXUAppName_cp = fSrcApp + fileName;
- fXUAppName_cp_o = fObjApp + fileName + ".o";
- }
-
- fileName = "M" + fAppName + ".cp";
- if (this->Exists(fSrcApp + fileName))
- {
- fAnyCPlus = TRUE;
- fXMAppName_cp = fSrcApp + fileName;
- fXMAppName_cp_o = fObjApp + fileName + ".o";
- }
-
- fileName = fAppName + ".cp";
- if (this->Exists(fSrcApp + fileName))
- {
- fAnyCPlus = TRUE;
- fXAppName_cp = fSrcApp + fileName;
- fXAppName_cp_o = fObjApp + fileName + ".o";
- }
- }
-
- this->SetIE("XUAppName.h", fXUAppName_h);
- this->SetIE("XUAppName.cp", fXUAppName_cp);
- this->SetIE("XUAppName.cp.o", fXUAppName_cp_o);
- this->SetIE("XMAppName.cp", fXMAppName_cp);
- this->SetIE("XMAppName.cp.o", fXMAppName_cp_o);
- this->SetIE("XAppName.cp", fXAppName_cp);
- this->SetIE("XAppName.cp.o", fXAppName_cp_o);
-
- // See if we can automake it
- if (!Exists(fAppPath + fAppName + fMAMakeFileExtension))
- {
- fAutomake = TRUE;
- if (!fAnyCPlus && !fRSRC)
- {
- this->Failed("Bad parameter: Unable to access file: \"{XAppPath}{XAppName}{MAMakeFileExtension}\"");
- }
- }
- else
- fAutomake = FALSE;
-
- // See if we can autorez it
- if (!Exists(fAppPath + fAppName + ".r"))
- {
- fAutorez = TRUE;
- this->SetIE("XAutoRez", "1");
- this->SetIE("XAppRezSrc", "{MAFramework}Includes:Default.r");
- }
- else
- {
- fAutorez = FALSE;
- this->SetIE("XAutoRez", "0");
- this->SetIE("XAppRezSrc", "{XAppPath}{XAppName}.r");
- }
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::DoATarget_Part2:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::DoATarget_Part2()
- {
- // Make sure alternate build folder exists and AppName folder in build folder.
- this->CreateObjectsFolder();
-
- // SET the BuildFlags
- {
- CStr255 MABuildFlagsExtension;
- IEgetenv("MABuildFlagsExtension", MABuildFlagsExtension);
- fBuildFlags = fObjApp + fAppName + MABuildFlagsExtension;
- }
- this->SetIE("BuildFlags", fBuildFlags);
-
- // Find out what the last option flags were
- Boolean existsBuildFlags = Exists(fBuildFlags);
- if (existsBuildFlags)
- this->Execute("EXECUTE \"{BuildFlags}\" ∑ Dev:NULL || SET Status 0");
- else
- this->SetIE("XLastOptionFlags", "InvalidString");
-
- if (fExecute)
- {
- this->Execute("IF {XLastOptionFlags} != {XOptionFlags}");
- // the file BuildFlags will contain a SET command to set the value of XLastOptionFlags
- this->Execute("ECHO \"SET XLastOptionFlags {XOptionFlags}\" > \"{BuildFlags}\"");
- this->Execute("END");
- }
- else if (!existsBuildFlags)
- {
- // the file BuildFlags will contain a SET command to set the value of XLastOptionFlags
- this->Echo("\"SET XLastOptionFlags {XOptionFlags}\" > \"{BuildFlags}\"");
- }
-
- // Rebuild the application by creating the "MakeIt" file and then executing it
- this->SetIE("XMakeIt", "{ObjApp}{XAppName}{MAMakeOutfileExtension}");
-
- // SET the failure processing mode in the makeit files and (OPTIONALLY) the
- // active environment vars into the makefile
- if (fNoFail)
- this->Execute("ECHO \"SET EXIT 0\" > \"{XMakeIt}\"");
- else
- this->Execute("ECHO \"SET EXIT 1\" > \"{XMakeIt}\"");
-
- // if (fExpandEnvironmentVars)
- // this->ExpandEnvironmentVars();
-
- // // Export the various and sundry environment variables
- // if (!fEverExported)
- // {
- // fEverExported = TRUE; // only need to export once
- // this->ExportEnvironmentVars();
- // }
-
- //if (!fRSRC)
- //{
- // Give user makefile processing status message
- if (fProgress)
- {
- if (fAutomake)
- this->Echo("\"AutoMaking: {XAppName}\"");
- else
- this->Echo("\"Making: {XAppName}{MAMakeFileExtension}\"");
- }
- //}
-
- if (fTimes)
- this->SetIE("XMakeStartTime", "`DATE -n`");
- this->SetIE("EXIT", "0");
-
- // Create the make file
- this->CreateMakeFile();
-
- // run make
- this->MakeTarget();
-
- this->SetIE("XMakeStatus", "{Status}");
- this->SetIE("EXIT", "1");
- this->Execute("IF \"{XMakeStatus}\"");
- this->Echo("MAKE of {XAppName} failed: `DATE`");
- if (fTimes)
- this->Echo("Elapsed time: `evaluate ∂`DATE -n∂` - {XMakeStartTime}` seconds");
- this->Execute("{MAFailed}");
- if (fNoFail)
- this->SetIE("XExitStatus", "{XMakeStatus}");
- else
- this->Execute("EXIT \"{XMakeStatus}\"");
-
- if (fTimes)
- {
- this->Execute("ELSE");
- this->Echo("Elapsed time: `evaluate ∂`DATE -n∂` - {XMakeStartTime}` seconds");
- }
- this->Execute("END");
-
- // Attempt Execution and let the user know how it all came out
- if (fExecute)
- {
- this->SetIE("EXIT", "0");
- this->Execute("\"{XMakeIt}\"");
- this->SetIE("XRunStatus", "{Status}");
- this->SetIE("EXIT", "1");
- this->Execute("IF \"{XRunStatus}\"");
- this->Execute("{MAFailed}");
- if (fNoFail)
- this->SetIE("XExitStatus", "{XRunStatus}");
- else
- this->Execute("EXIT \"{XRunStatus}\"");
- this->Execute("END");
- }
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::ExpandEnvironmentVars:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::ExpandEnvironmentVars()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::ExportEnvironmentVars:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::ExportEnvironmentVars()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::CreateMakeFile:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::CreateMakeFile()
- {
- CStr255 makeFileName = fObjApp + fAppName + ".make";
- fMakeFile = fopen(makeFileName, "w");
-
- fprintf(fMakeFile, "# %s\n", (const char *) makeFileName);
- {
- unsigned long theDateTime;
- CStr255 theDateTimeString;
-
- GetDateTime(&theDateTime);
-
- IUTimeString(theDateTime, TRUE, theDateTimeString);
- fprintf(fMakeFile, "# Created by MABuild: %s", (const char *)theDateTimeString);
-
- IUDateString(theDateTime, shortDate, theDateTimeString);
- fprintf(fMakeFile, " %s\n\n", (const char *)theDateTimeString);
- }
-
- this->OutputMakeVariables();
-
- this->DoDefinitions();
-
- if (fAutomake)
- this->SetMakeVariable("AppName", fAppName); // the default rules supply the rest
-
- if (fFat)
- this->SetMakeVariable("Merge68K", fAppName68K);
-
- this->DoOverrides();
-
- if (!fAutomake)
- this->CatenateMake(fAppPath + fAppName + fMAMakeFileExtension); // a makefile was supplied
-
- this->DoDependencies();
-
- fclose(fMakeFile);
-
- // The makefile is opened with a creator of 'TTXT'
- // The easiest way to patch it is in the script
- this->Execute("SetFile -c 'MPS ' \"" + makeFileName + "\"");
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::CatenateMake:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::CatenateMake(const CStr255& fileName)
- {
- CatenateFile(fileName, fMakeFile);
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::MakeTarget:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::MakeTarget()
- {
- // run make
- this->Execute("{MAMake} {MakeOptions} ∂");
- this->Execute("-f \"{ObjApp}{XAppName}.make\" ∂");
-
- // Supply a target
- if (fRSRC)
- {
- if (fAppName == "MacApp.lib.xcoff")
- this->Execute("\"{ObjApp}MacApp.Lib.π.rsrc\" ∂");
- else
- this->Execute("\"{ObjApp}{XAppName}.π.rsrc\" ∂");
- }
- else
- this->Execute("\"{ObjApp}{XAppName}\" ∂");
-
- if (!fStatusOnly)
- this->Execute(">> \"{XMakeIt}\"");
- else
- this->Execute("");
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::DoOverrides:
- //----------------------------------------------------------------------------------------
- #pragma segment TRes
-
- void TMABuildTool::DoOverrides()
- {
- // MacApp as library support
- if (fMALibrary)
- this->SetMakeVariable("MacAppObjs=");
- else
- this->SetMakeVariable("MacAppLibrary=");
-
- if (fCPlusLoad)
- {
- // If we don't have a RAM disk, just use the original C++ load files
- if (fRAMDisk)
- this->SetMakeVariable("CPlusLoadOriginal=");
- else
- this->SetMakeVariable("CPlusLoadCopy=");
- }
- else
- {
- this->SetMakeVariable("CPlusLoad=");
- this->SetMakeVariable("CPlusLoadObj=");
- this->SetMakeVariable("CPlusLoadOptions="); // Remove the definitions
- this->SetMakeVariable("CPlusLoadOriginal=");
- this->SetMakeVariable("CPlusLoadCopy=");
- }
-
- // Debugging support
- if (!fDebug)
- {
- this->SetMakeVariable("DebugFiles=");
- this->SetMakeVariable("DebugRsrcs=");
- this->SetMakeVariable("DebugLib="); // Eliminate debug files as targets in the makefiles
- }
-
- // Performance analysis support
- if (!fPerform)
- this->SetMakeVariable("PerformLib=");
-
- if (fCompiler == kwMWC68K || fCompiler == kwMWCPPC)
- {
- this->SetMakeVariable("MAPrefixFile=");
- this->SetMakeVariable("LoadFileOutput=");
- this->SetMakeVariable("Stubs=");
- }
- else
- {
- this->SetMakeVariable("CLoadOptions=");
- this->SetMakeVariable("CWPrefixFile=");
- }
-
- if (fCompiler == kwMWC68K)
- {
- // Select the proper CodeWarrior floating point support
- if (fNeedsFPU)
- {
- this->SetMakeVariable("CWLibrariesNoFPU=");
- this->SetMakeVariable("CWNearNonFPUStdCLib=");
- this->SetMakeVariable("CWFarNonFPUStdCLib=");
- this->SetMakeVariable("CWToolNearNonFPUStdCLib=");
- this->SetMakeVariable("CWToolFarNonFPUStdCLib=");
- }
- else
- {
- this->SetMakeVariable("CWFPUSANELib=");
- this->SetMakeVariable("CWNearFPUStdCLib=");
- this->SetMakeVariable("CWFarFPUStdCLib=");
- this->SetMakeVariable("CWToolNearFPUStdCLib=");
- this->SetMakeVariable("CWToolFarFPUStdCLib=");
- }
-
- // Select the proper CodeWarrior run-time model
- if (fModelFarData || fModelFar)
- {
- this->SetMakeVariable("CWNearFPUStdCLib=");
- this->SetMakeVariable("CWNearNonFPUStdCLib=");
- this->SetMakeVariable("CWToolNearFPUStdCLib=");
- this->SetMakeVariable("CWToolNearNonFPUStdCLib=");
- }
- else
- {
- this->SetMakeVariable("CWFarNonFPUStdCLib=");
- this->SetMakeVariable("CWFarFPUStdCLib=");
- this->SetMakeVariable("CWToolFarNonFPUStdCLib=");
- this->SetMakeVariable("CWToolFarFPUStdCLib=");
- }
- }
- else if (!fPowerPC)
- {
- // Select the proper floating point support
- if (fNeedsFPU)
- this->SetMakeVariable("LibrariesNoFPU=");
- else
- this->SetMakeVariable("LibrariesFPU=");
-
- // Select the proper link libraries for modelfar support by eliminating
- // the definition of ModelFarSupport if it's not used
- if (!fModelFar)
- this->SetMakeVariable("ModelFarSupport=");
- }
-
- // Drag & Drop Support
- if (!fDrag)
- {
- // Knock out the Drag & Drop support
- this->SetMakeVariable("DragLib=");
- if (fPowerPC || fModelCFM)
- this->SetMakeVariable("DragLibMapping=");
- }
-
- // PowerTalk Mailer Support
- if (!fPowerTalk)
- {
- // Knock out the AOCE support
- this->SetMakeVariable("AOCELib=");
- if (fPowerPC || fModelCFM)
- this->SetMakeVariable("AOCELibMapping=");
- }
-
- //GXPrinting Support
- if (!fGXPrinting)
- {
- // Knock out the GX support
- this->SetMakeVariable("GXLib=");
- if (fPowerPC || fModelCFM)
- this->SetMakeVariable("GXLibMapping=");
- }
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::DoDefinitions:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::DoDefinitions()
- {
- CStr255 MADependencies;
- IEgetenv("MADependencies", MADependencies);
-
- // RSRC has to go first because it overrides PPC or 68K
- if (fRSRC)
- this->CatenateMake(MADependencies + "Definitions_RSRC");
- else
- {
- this->CatenateMake(MADependencies + "Definitions_Common");
-
- if (fPowerPC)
- {
- this->CatenateMake(MADependencies + "Definitions_PPC");
- if (fCompiler == kwMrC)
- this->CatenateMake(MADependencies + "Definitions_MrC");
- else if (fCompiler == kwMWCPPC)
- this->CatenateMake(MADependencies + "Definitions_MWPPC");
- else
- this->CatenateMake(MADependencies + "Definitions_PPCC");
- }
- else
- {
- this->CatenateMake(MADependencies + "Definitions_68K");
- if (fModelCFM)
- this->CatenateMake(MADependencies + "Definitions_CFM68K");
- else if (fClassic)
- this->CatenateMake(MADependencies + "Definitions_Classic");
- else if (fCompiler == kwSCpp)
- this->CatenateMake(MADependencies + "Definitions_SC");
- else if (fCompiler == kwMWC68K)
- this->CatenateMake(MADependencies + "Definitions_MW68K");
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::DoDependencies:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::DoDependencies()
- {
- CStr255 MADependencies;
- IEgetenv("MADependencies", MADependencies);
-
- // RSRC has to go first because it overrides PPC or 68K
- if (fRSRC)
- this->CatenateMake(MADependencies + "Dependencies_RSRC");
- else if (fPowerPC)
- {
- if (fFast)
- this->CatenateMake(MADependencies + "Fast_Dependencies_PPC");
- else
- this->CatenateMake(MADependencies + "Dependencies_PPC");
- }
- else
- {
- if (fFast)
- this->CatenateMake(MADependencies + "Fast_Dependencies_68K");
- else
- this->CatenateMake(MADependencies + "Dependencies_68K");
- }
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::SetMakeVariable:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::SetMakeVariable(const CStr255& theVariable,
- TStringHandle* theValue)
- {
- fprintf(fMakeFile, "%s = ", (const char *)theVariable);
- theValue->WriteToFile(fMakeFile);
- fprintf(fMakeFile, "\n");
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::SetMakeVariable:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::SetMakeVariable(const CStr255& theVariable,
- const CStr255& theValue)
- {
- fprintf(fMakeFile, "%s = %s\n", (const char *)theVariable, (const char *)theValue);
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::SetMakeVariable:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::SetMakeVariable(const CStr255& theVariable,
- Boolean theValue)
- {
- short boolAsShort = theValue;
- fprintf(fMakeFile, "%s = %i\n", (const char *)theVariable, boolAsShort);
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::SetMakeVariable:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::SetMakeVariable(const CStr255& aString)
- {
- fprintf(fMakeFile, "%s\n", (const char *)aString);
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::SetMakeIE:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::SetMakeIE(const CStr255& theVariable)
- {
- CStr255 theValue;
- IEgetenv(theVariable, theValue);
- fprintf(fMakeFile, "%s = %s\n", (const char *)theVariable, (const char *)theValue);
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::SetMakeIE:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::SetMakeIE(const CStr255& theVariable,
- const CStr255& theIEVariable)
- {
- CStr255 theValue;
- IEgetenv(theIEVariable, theValue);
- fprintf(fMakeFile, "%s = %s\n", (const char *)theVariable, (const char *)theValue);
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::OutputMakeVariables:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::OutputMakeVariables()
- {
- // output the results.
- // if (fTimes)
- // fprintf(fOutputFile," Echo XStartTime = %li\n", fStartDateTime);
-
- this->SetMakeVariable("XTimes", fTimes);
- this->SetMakeVariable("XRunAfterBuild", fRunAfterBuild);
- this->SetMakeVariable("XUseRAMDisk", fRAMDisk && fCPlusLoad);
- this->SetMakeVariable("XRAMDiskName", fRAMDiskName);
- // if (fRAMDisk && fCPlusLoad)
- // this->SetMakeVariable("XRAMDiskLoad = 0");
- this->SetMakeVariable("LoadFileDir", fObjApp);
-
- this->SetMakeIE("CIncludes");
- this->SetMakeIE("MACPlusIncludes");
- this->SetMakeIE("MARIncludes");
- this->SetMakeIE("MALibraries");
-
- this->SetMakeIE("MAAsmPaths");
- this->SetMakeIE("MACPlusPaths");
- this->SetMakeIE("MARezPaths");
-
- this->SetMakeIE("MAApp");
- this->SetMakeIE("MACore");
- this->SetMakeIE("MADocs");
- this->SetMakeIE("MAFramework");
- this->SetMakeIE("MAMail");
- this->SetMakeIE("MATool");
- this->SetMakeIE("MAViews");
-
- this->SetMakeIE("MAAsm");
- this->SetMakeIE("MAC");
- this->SetMakeIE("MACPlus");
- this->SetMakeIE("MAEcho");
- this->SetMakeIE("MALib");
- this->SetMakeIE("MARez");
-
- this->SetMakeVariable("AsmOptions", fAsmOptions);
-
- if (!fPowerPC)
- {
- if (fCompiler == kwMWC68K )
- {
- this->SetMakeVariable("CPlusOptions", fMWC68KOptions);
- this->SetMakeVariable("COptions", fMWC68KOptions);
- this->SetMakeVariable("SCOptions =");
- this->SetMakeIE("MAC", "MAmwc68K");
- this->SetMakeIE("MACPlus", "MAmwc68K");
- }
- else
- {
- this->SetMakeVariable("COptions", fCOptions);
-
- if (fCompiler == kwSCpp)
- {
- this->SetMakeVariable("CPlusOptions =");
- this->SetMakeVariable("MAC = SC");
- this->SetMakeIE("MACPlus", "MASCpp");
- this->SetMakeVariable("SCOptions", fSCOptions);
- }
- else
- {
- this->SetMakeVariable("SCOptions =");
- this->SetMakeVariable("CPlusOptions", fCPlusOptions);
- }
- }
- this->SetMakeVariable("CPlusCPUOptions", fCPlusCPUOptions);
- }
- else // fPowerPC
- {
- this->SetMakeVariable("PPCAsmOptions", fPPCAsmOptions);
-
- if (fCompiler == kwMWCPPC)
- {
- this->SetMakeIE("MAPPCC", "MAmwCPPC");
- this->SetMakeIE("MAPPCLink", "MAmwLinkPPC");
- this->SetMakeVariable("MrCOptions =");
- this->SetMakeVariable("PPCCOptions", fMWCPPCOptions);
- }
- else if (fCompiler == kwMrC)
- {
- this->SetMakeVariable("PPCCOptions =");
- this->SetMakeIE("MAPPCC", "MAMrCPlus");
- this->SetMakeVariable("MrCOptions", fMrCOptions);
- }
- else
- {
- this->SetMakeVariable("MrCOptions =");
- this->SetMakeVariable("PPCCOptions", fPPCCOptions);
- }
- }
-
- this->SetMakeVariable("EchoOptions", fEchoOptions);
-
- if (fCompiler == kwMWC68K)
- {
- this->SetMakeIE("MALink", "MAmwLink68K");
- this->SetMakeVariable("LinkOptions", fMWLink68KOptions);
- this->SetMakeIE("MALib", "MAmwLink68K");
-
- fprintf(fMakeFile, "LibOptions = -library ");
- fMWLink68KOptions->WriteToFile(fMakeFile);
- fprintf(fMakeFile, "\n");
- }
- else
- {
- this->SetMakeVariable("LibOptions", fLibOptions);
- this->SetMakeVariable("LinkOptions", fLinkOptions);
- }
-
- if (fModelCFM)
- {
- this->SetMakeIE("MALink", "MAILink");
- }
-
- if (fPowerPC)
- {
- if (fCompiler == kwMWCPPC)
- {
- fprintf(fMakeFile, "PPCLibOptions = -xm library ");
- fMWLinkPPCOptions->WriteToFile(fMakeFile);
- fprintf(fMakeFile, "\n");
-
- this->SetMakeVariable("PPCLinkOptions", fMWLinkPPCOptions);
- }
- else
- {
- this->SetMakeVariable("PPCLibOptions", fPPCLibOptions);
- this->SetMakeVariable("PPCLinkOptions", fPPCLinkOptions);
- }
-
- this->SetMakeVariable("MakeSymOptions", fMakeSymOptions);
- }
-
- this->SetMakeVariable("RunTimeModel", fRunTimeModel);
-
- if (fCompiler == kwMWC68K || fCompiler == kwMWCPPC)
- this->SetMakeIE("CIncludes", "CWExtraFiles");
-
- // if (fFast)
- // {
- // fprintf(fOutputFile, "SET All_Cpp_Files \"\"\n");
- // fprintf(fOutputFile, "SET All_Cpp_Names \"\"\n");
- // fprintf(fOutputFile, "SET All_C_Files \"\"\n");
- // fprintf(fOutputFile, "SET All_C_Names \"\"\n");
- // }
-
- //this->SetMakeVariable("MakeOptions", fMakeOptions);
- this->SetMakeVariable("RezOptions", fRezOptions);
- this->SetMakeVariable("CreatorAndBundleOptions", fCreatorAndBundleOptions);
- this->SetMakeVariable("XOptionFlags", fOptionFlags);
-
- this->SetMakeVariable("SeparateObjectsFolder", fSeparateObjectsFolder);
- this->SetMakeVariable("BuildFolder", fBuildFolder);
- this->SetMakeVariable("MAObj", fMAObj);
- this->SetMakeVariable("XAppPath", fAppPath);
- this->SetMakeVariable("ObjApp", fObjApp);
- this->SetMakeVariable("SrcApp", fSrcApp);
- this->SetMakeVariable("IncApp", fIncApp);
-
- this->SetMakeVariable("XLinkMap", fXLinkMap);
- this->SetMakeVariable("XLinkXRef", fXLinkXRef);
-
- this->SetMakeVariable("XAppName", fAppName);
- this->SetMakeVariable("XUAppName.h", fXUAppName_h);
- this->SetMakeVariable("XUAppName.cp", fXUAppName_cp);
- this->SetMakeVariable("XUAppName.cp.o", fXUAppName_cp_o);
- this->SetMakeVariable("XMAppName.cp", fXMAppName_cp);
- this->SetMakeVariable("XMAppName.cp.o", fXMAppName_cp_o);
- this->SetMakeVariable("XAppName.cp", fXAppName_cp);
- this->SetMakeVariable("XAppName.cp.o", fXAppName_cp_o);
-
- this->SetMakeVariable("XAutoRez", fAutorez);
- if (fAutorez)
- this->SetMakeVariable("XAppRezSrc", "{MAFramework}Includes:Default.r");
- else
- this->SetMakeVariable("XAppRezSrc", fAppPath + fAppName + ".r");
-
- this->SetMakeVariable("BuildFlags", fBuildFlags);
- this->SetMakeVariable("XMakeIt", fObjApp + fAppName + "{MAMakeOutfileExtension}");
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::OutputTheEnd:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::OutputTheEnd()
- {
- // Close the output file.
- if (fOutputFile != stdout)
- fclose(fOutputFile);
-
- // termination messages
- if (fTimes)
- {
- this->Echo("\" \"");
- this->Echo("MABuild: Elapsed time: `evaluate ∂`DATE -n∂` - {XStartTime}` seconds");
- }
-
- this->Execute("IF \"{XExitStatus}\"");
- this->Execute("{MAFailed}");
- this->Execute("EXIT \"{XExitStatus}\"");
- this->Execute("END");
-
- if (fProgress)
- {
- this->Echo("Completion time for MABuild is `DATE`");
- this->Execute("{MADone}");
- }
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::SetOutputFile:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::SetOutputFile(const CStr255& outputFileName)
- {
- fOutputFile = fopen(outputFileName, "w");
- if (fOutputFile == NULL)
- {
- this->Stop("MABuild: Unable to create or open output file.");
- }
- }
-
- //----------------------------------------------------------------------------------------
- // TMABuildTool::DoToolAction:
- //----------------------------------------------------------------------------------------
- #pragma segment ANonRes
-
- void TMABuildTool::DoToolAction()
- {
- {
- CStr255 MAShortVersion;
- if (!IEgetenv("MAShortVersion", MAShortVersion))
- {
- this->Stop("MABuild: Whoops… You have not executed the Startup file in the MacApp directory");
- }
- else if (MAShortVersion != MA_SHORT_VERSION)
- {
- fprintf(stderr, "\nMABuild: Warning: The MacApp version seems to be '%s'; should be '%s'\n",
- (const char *) MAShortVersion, MA_SHORT_VERSION);
- }
- }
-
- // Resolve matrix of options.
- this->CheckKeywords();
-
- // Set up the option flags.
- this->DoOptionFlags_Part1();
- this->DoOptionFlags_Part2();
-
- if (fGetBuildFlags || fGetFolderName)
- {
- if (fGetFolderName)
- this->Execute("ECHO \"{SeparateObjectsFolder}\"");
- else
- {
- fprintf(fOutputFile, "SET XOptionFlags \"");
- fOptionFlags->WriteToFile(fOutputFile);
- fprintf(fOutputFile, "\"\n");
- this->Execute("ECHO \"{XOptionFlags}\"");
- }
- return;
- }
-
- // Get the autobuild targets, if any.
- this->GetAutoBuild();
-
- // output the results.
- this->OutputOptionFlags();
-
- // Process autosave
- if (fSaveBeforeBuild)
- {
- if (fProgress)
- this->Echo("\"AutoSaving…\"");
- this->Execute("Save -a");
- }
-
- // Remember the current directory
- short vRefNum;
- long dirID;
- if (HGetVol(NULL, &vRefNum, &dirID) == noErr)
- PathNameFromDirID(dirID, vRefNum, fStartPath);
-
- // Create the alternate build folder
- this->CreateBuildFolder();
-
- // process each target in the list
- this->DoAllTargets();
-
- // termination messages
- this->OutputTheEnd();
- }
-
- //----------------------------------------------------------------------------------------
- // main:
- //----------------------------------------------------------------------------------------
- #pragma segment Main
-
- void main(int argc, char** argv)
- {
- InitUCPlusTool();
-
- gMABuildTool = new TMABuildTool;
- gMABuildTool->IMABuildTool(argc, argv);
- gMABuildTool->Run();
- }
-
- //----------------------------------------------------------------------------------------
- // End of MABuildTool.cp
-
- #pragma segment Inline
-